How shivgobindmourya/dsa-lab-programs works
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: 04_binary_search.cpp Binary Search · 05_bubble_sort_with_passes.cpp Bubble Sort · 06_insertion_sort.cpp Insertion Sort · 07_merge_sort_recursive.cpp Merge Sort
Components 20
Recursion
Foundational recursive examples for stack and computation behavior.
Arrays
Array manipulation, searching, sorting, and address arithmetic labs.
- Array Ops · Insertion, deletion, and traversal over a linear array.
20_DSA_program/03_array_insert_delete_traverse.cpp - Binary Search · Searches a sorted array using binary search.
20_DSA_program/04_binary_search.cpp - Bubble Sort · Bubble sort with pass-by-pass visibility.
20_DSA_program/05_bubble_sort_with_passes.cpp - Insertion Sort · Insertion sort over an array, emphasizing ordered growth.
20_DSA_program/06_insertion_sort.cpp - Merge Sort · Recursive divide-and-conquer merge sort example.
20_DSA_program/07_merge_sort_recursive.cpp - 2D Addressing · 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 · Stack implemented with a fixed-size array.
20_DSA_program/09_stack_using_array.cpp - Stack List · Stack implemented with linked nodes.
20_DSA_program/10_stack_using_linkedlist.cpp - Queue Array · Queue implemented with a fixed-size array.
20_DSA_program/11_queue_using_array.cpp - Queue List · Queue implemented with linked nodes.
20_DSA_program/12_queue_using_linkedlist.cpp - Two-Stack Queue · Queue behavior emulated using two stacks.
20_DSA_program/13_queue_using_two_stacks.cpp - List Insert · Singly linked list insertion and pointer relinking.
20_DSA_program/14_singly_linked_list_insertion.cpp - List Delete · 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 · Binary tree stored in array form using index relationships.
20_DSA_program/16_binary_tree_array_representation.cpp - Traversals · Preorder, inorder, and postorder traversal programs.
20_DSA_program/17_tree_traversals.cpp - Max Heap · 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 · Graph stored as an adjacency matrix.
20_DSA_program/19_graph_adjacency_matrix.cpp - BFS · Breadth-first search over a graph representation.
20_DSA_program/20_BFS_traversal.cpp
Connections 17
- 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.