# shivgobindmourya/dsa-lab-programs architecture

> Architecture diagram of the GitHub repository shivgobindmourya/dsa-lab-programs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shivgobindmourya/dsa-lab-programs
- Repository: https://github.com/shivgobindmourya/dsa-lab-programs

## Overview

1. **Repository shape**
   - This is a collection of **20 independent C++ lab programs**, not a single integrated application.
   - Each `.cpp` file is a **standalone executable** with its own `main`, input/output flow, and algorithm demonstration.
   - There is **no shared library layer, no build system, and no cross-file dependency graph** in the repo as shown.

2. **Overall architectural boundary**
   - The main boundary is **per-program isolation**: each file implements one data-structure or algorithm exercise end-to-end.
   - The repo is organized as a **teaching/lab artifact**, so the architecture is driven by topic separation rather than reusable software components.

3. **Recursion and basic computation layer**
   - `01_fibonacci_recursive.cpp` and `02_factorial_recursive.cpp` form the simplest computation examples.
   - These programs demonstrate **recursive control flow** and likely take a numeric input, compute a result, and print it directly.
   - They serve as foundational examples for understanding call stack behavior before moving into data structures.

4. **Array operations and searching/sorting layer**
   - `03_array_insert_delete_traverse.cpp`, `04_binary_search.cpp`, `05_bubble_sort_with_passes.cpp`, `06_insertion_sort.cpp`, `07_merge_sort_recursive.cpp`, and `08_2D_array_address_calculation.cpp` are array-focused.
   - This layer shows the progression from **basic array manipulation** to **searching, sorting, and memory/address reasoning**.
   - The data flow is typically: read input array → process in-place or recursively → display intermediate/final state.
   - `08_2D_array_address_calculation.cpp` is distinct because it is about **memory layout math** rather than an algorithm over values.

5. **Linear data structures: stacks and queues**
   - `09_stack_using_array.cpp`, `10_stack_using_linkedlist.cpp`, `11_queue_using_array.cpp`, `12_queue_using_linkedlist.cpp`, and `13_queue_using_two_stacks.cpp` implement classic linear ADTs.
   - These programs emphasize **two internal representations** for the same logical structure: array-based and pointer-based.
   - `13_queue_using_two_stacks.cpp` is a bridge example showing how one ADT can be built from another, with items flowing through stack operations to emulate queue behavior.

6. **Linked list subsystem**
   - `14_singly_linked_list_insertion.cpp` and `15_singly_linked_list_deletion.cpp` focus on **node-based dynamic memory management**.
   - The architectural boundary here is the linked-node chain, where operations mutate head/middle/tail links rather than contiguous memory.
   - These programs likely demonstrate pointer updates as the key data flow: input position/value → node creation or removal → pointer re-linking → traversal output.

7. **Tree subsystem**
   - `16_binary_tree_array_representation.cpp` and `17_tree_traversals.cpp` cover hierarchical structures.
   - `16` uses an **array representation of a binary tree**, which maps parent-child relationships by index.
   - `17` focuses on **tree traversal algorithms**: preorder, inorder, and postorder, emphasizing recursive or stack-based navigation of hierarchical data.

8. **Heap subsystem**
   - `18_max_heap_heapify.cpp` is the only heap-specific program.
   - It demonstrates the **heap property** and the `heapify` transformation, likely starting from an array and rearranging it into a max-heap.
   - Architecturally, this sits between arrays and trees: the data is stored in an array but interpreted as a complete binary tree.

9. **Graph subsystem**
   - `19_graph_adjacency_matrix.cpp` and `20_BFS_traversal.cpp` form the graph section.
   - `19` establishes graph storage using an **adjacency matrix**, which is a dense, matrix-based representation.
   - `20` performs **Breadth-First Search**, consuming the graph representation and visiting vertices level by level, typically via a queue.
   - This is the most connected subsystem in the repo because BFS depends on both graph structure and traversal state.

10. **Common runtime and tooling**
   - The repository targets **C++ compiled with g++/GNU C++**, and the README mentions **VS Code**, Linux/GCC, and Windows/MinGW compatibility.
   - There are no external services, databases, or package managers involved; execution is local and console-based.
   - The dominant interaction model is **stdin/stdout**, which makes each program easy to test independently from the terminal.

11. **How to draw the architecture**
   - Represent the repo as **20 isolated program boxes**, grouped into five clusters: recursion, arrays/sorting, linear DS, trees/heaps, and graphs.
   - Show each box feeding from **user input to algorithm processing to console output**.
   - Avoid drawing inter-file dependencies, because the repository does not show shared modules or runtime composition between programs.

12. **Key takeaway**
   - This repo is best understood as a **curriculum-aligned set of algorithm demonstrations**, not a layered software system.
   - Its architecture is a taxonomy of classic DSA topics, with each source file acting as a self-contained implementation of one concept.

Main entry points: [`20_DSA_program/04_binary_search.cpp`](https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/04_binary_search.cpp) (Binary Search), [`20_DSA_program/05_bubble_sort_with_passes.cpp`](https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/05_bubble_sort_with_passes.cpp) (Bubble Sort), [`20_DSA_program/06_insertion_sort.cpp`](https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/06_insertion_sort.cpp) (Insertion Sort), [`20_DSA_program/07_merge_sort_recursive.cpp`](https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/07_merge_sort_recursive.cpp) (Merge Sort)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g_recursion["Recursion"]
  node_n01["Fibonacci<br/>recursive demo"]
  node_n02["Factorial<br/>recursive demo"]
end

subgraph group_g_arrays["Arrays"]
  node_n03["Array Ops<br/>array demo"]
  node_n04["Binary Search<br/>search demo"]
  node_n05["Bubble Sort<br/>sort demo"]
  node_n06["Insertion Sort<br/>sort demo"]
  node_n07["Merge Sort<br/>recursive sort"]
  node_n08["2D Addressing<br/>memory layout"]
end

subgraph group_g_linear["Linear DS"]
  node_n09["Stack Array<br/>stack impl"]
  node_n10["Stack List<br/>stack impl"]
  node_n11["Queue Array<br/>queue impl"]
  node_n12["Queue List<br/>queue impl"]
  node_n13["Two-Stack Queue<br/>queue bridge"]
  node_n14["List Insert<br/>linked list"]
  node_n15["List Delete<br/>linked list"]
end

subgraph group_g_trees["Trees & Heap"]
  node_n16["Tree Array<br/>tree repr"]
  node_n17["Traversals<br/>tree algo"]
  node_n18["Max Heap<br/>heap algo"]
end

subgraph group_g_graphs["Graphs"]
  node_n19["Adj Matrix<br/>graph repr"]
  node_n20["BFS<br/>graph traversal"]
end

node_n01 -->|"recursive examples"| node_n02
node_n03 -->|"searches"| node_n04
node_n04 -->|"sorting"| node_n05
node_n05 -->|"sort variants"| node_n06
node_n06 -->|"recursive sort"| node_n07
node_n07 -->|"memory math"| node_n08
node_n08 -->|"linear ds"| node_n09
node_n09 -->|"alternate impl"| node_n10
node_n11 -->|"alternate impl"| node_n12
node_n12 -->|"bridge pattern"| node_n13
node_n13 -->|"node links"| node_n14
node_n14 -->|"mutations"| node_n15
node_n15 -->|"hierarchy"| node_n16
node_n16 -->|"traversal"| node_n17
node_n17 -->|"complete tree"| node_n18
node_n18 -->|"graph shift"| node_n19
node_n19 -->|"bfs"| node_n20

click node_n01 "https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/01_fibonacci_recursive.cpp"
click node_n02 "https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/02_factorial_recursive.cpp"
click node_n03 "https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/03_array_insert_delete_traverse.cpp"
click node_n04 "https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/04_binary_search.cpp"
click node_n05 "https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/05_bubble_sort_with_passes.cpp"
click node_n06 "https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/06_insertion_sort.cpp"
click node_n07 "https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/07_merge_sort_recursive.cpp"
click node_n08 "https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/08_2D_array_address_calculation.cpp"
click node_n09 "https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/09_stack_using_array.cpp"
click node_n10 "https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/10_stack_using_linkedlist.cpp"
click node_n11 "https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/11_queue_using_array.cpp"
click node_n12 "https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/12_queue_using_linkedlist.cpp"
click node_n13 "https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/13_queue_using_two_stacks.cpp"
click node_n14 "https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/14_singly_linked_list_insertion.cpp"
click node_n15 "https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/15_singly_linked_list_deletion.cpp"
click node_n16 "https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/16_binary_tree_array_representation.cpp"
click node_n17 "https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/17_tree_traversals.cpp"
click node_n18 "https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/18_max_heap_heapify.cpp"
click node_n19 "https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/19_graph_adjacency_matrix.cpp"
click node_n20 "https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/20_BFS_traversal.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_n01,node_n02 toneBlue
class node_n03,node_n04,node_n05,node_n06,node_n07,node_n08 toneAmber
class node_n09,node_n10,node_n11,node_n12,node_n13,node_n14,node_n15 toneMint
class node_n16,node_n17,node_n18 toneRose
class node_n19,node_n20 toneIndigo
```

## Components

### Recursion

Foundational recursive examples for stack and computation behavior.

- [Fibonacci](https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/01_fibonacci_recursive.cpp): recursive demo · Standalone recursive Fibonacci program with direct console I/O. · `20_DSA_program/01_fibonacci_recursive.cpp`
- [Factorial](https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/02_factorial_recursive.cpp): recursive demo · Standalone recursive factorial program with direct console I/O. · `20_DSA_program/02_factorial_recursive.cpp`

### Arrays

Array manipulation, searching, sorting, and address arithmetic labs.

- [Array Ops](https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/03_array_insert_delete_traverse.cpp): array demo · Insertion, deletion, and traversal over a linear array. · `20_DSA_program/03_array_insert_delete_traverse.cpp`
- [Binary Search](https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/04_binary_search.cpp): search demo · Searches a sorted array using binary search. · `20_DSA_program/04_binary_search.cpp`
- [Bubble Sort](https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/05_bubble_sort_with_passes.cpp): sort demo · Bubble sort with pass-by-pass visibility. · `20_DSA_program/05_bubble_sort_with_passes.cpp`
- [Insertion Sort](https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/06_insertion_sort.cpp): sort demo · Insertion sort over an array, emphasizing ordered growth. · `20_DSA_program/06_insertion_sort.cpp`
- [Merge Sort](https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/07_merge_sort_recursive.cpp): recursive sort · Recursive divide-and-conquer merge sort example. · `20_DSA_program/07_merge_sort_recursive.cpp`
- [2D Addressing](https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/08_2D_array_address_calculation.cpp): memory layout · Computes 2D array addresses and index-to-memory mapping. · `20_DSA_program/08_2D_array_address_calculation.cpp`

### Linear DS

Stacks, queues, and linked-list implementations.

- [Stack Array](https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/09_stack_using_array.cpp): stack impl · Stack implemented with a fixed-size array. · `20_DSA_program/09_stack_using_array.cpp`
- [Stack List](https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/10_stack_using_linkedlist.cpp): stack impl · Stack implemented with linked nodes. · `20_DSA_program/10_stack_using_linkedlist.cpp`
- [Queue Array](https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/11_queue_using_array.cpp): queue impl · Queue implemented with a fixed-size array. · `20_DSA_program/11_queue_using_array.cpp`
- [Queue List](https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/12_queue_using_linkedlist.cpp): queue impl · Queue implemented with linked nodes. · `20_DSA_program/12_queue_using_linkedlist.cpp`
- [Two-Stack Queue](https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/13_queue_using_two_stacks.cpp): queue bridge · Queue behavior emulated using two stacks. · `20_DSA_program/13_queue_using_two_stacks.cpp`
- [List Insert](https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/14_singly_linked_list_insertion.cpp): linked list · Singly linked list insertion and pointer relinking. · `20_DSA_program/14_singly_linked_list_insertion.cpp`
- [List Delete](https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/15_singly_linked_list_deletion.cpp): linked list · Singly linked list deletion and pointer relinking. · `20_DSA_program/15_singly_linked_list_deletion.cpp`

### Trees & Heap

Tree representations, traversals, and heap operations.

- [Tree Array](https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/16_binary_tree_array_representation.cpp): tree repr · Binary tree stored in array form using index relationships. · `20_DSA_program/16_binary_tree_array_representation.cpp`
- [Traversals](https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/17_tree_traversals.cpp): tree algo · Preorder, inorder, and postorder traversal programs. · `20_DSA_program/17_tree_traversals.cpp`
- [Max Heap](https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/18_max_heap_heapify.cpp): heap algo · Transforms an array into a max heap via heapify. · `20_DSA_program/18_max_heap_heapify.cpp`

### Graphs

Graph storage and BFS traversal labs.

- [Adj Matrix](https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/19_graph_adjacency_matrix.cpp): graph repr · Graph stored as an adjacency matrix. · `20_DSA_program/19_graph_adjacency_matrix.cpp`
- [BFS](https://github.com/shivgobindmourya/dsa-lab-programs/blob/main/20_DSA_program/20_BFS_traversal.cpp): graph traversal · Breadth-first search over a graph representation. · `20_DSA_program/20_BFS_traversal.cpp`

## Connections

- Fibonacci → Factorial: recursive examples · Simple recursion exercises in sequence.
- Array Ops → Binary Search: searches · Array manipulation flows into searching.
- Binary Search → Bubble Sort: sorting · Search and sort examples within the array topic.
- Bubble Sort → Insertion Sort: sort variants · Bubble sort leads to insertion sort.
- Insertion Sort → Merge Sort: recursive sort · Progresses to a recursive divide-and-conquer sort.
- Merge Sort → 2D Addressing: memory math · Ends the array section with address calculation.
- 2D Addressing → Stack Array: linear ds · Array foundations lead into stack implementations.
- Stack Array → Stack List: alternate impl · Array-backed stack contrasted with linked-list stack.
- Queue Array → Queue List: alternate impl · Array-backed queue contrasted with linked-list queue.
- Queue List → Two-Stack Queue: bridge pattern · Queue behavior built from stacks.
- Two-Stack Queue → List Insert: node links · Queue and stack topics transition into linked lists.
- List Insert → List Delete: mutations · List insertion precedes list deletion.
- List Delete → Tree Array: hierarchy · Linked structures give way to tree representations.
- Tree Array → Traversals: traversal · Tree storage leads to tree traversal algorithms.
- Traversals → Max Heap: complete tree · Traversal work continues into heap structure.
- Max Heap → Adj Matrix: graph shift · Heap section transitions from tree to graph concepts.
- Adj Matrix → BFS: bfs · Adjacency matrix representation feeds BFS traversal.
