📖 Chapters
- 1. Introduction to DSA and Its Importance
- 2. Time and Space Complexity (Big O, Θ, Ω)
- 3. Recursion and Stack Memory
- 4. Mathematics for DSA (GCD, LCM, Modulo Arithmetic)
- 5. Arrays: Basics and Operations
- 6. Strings: Manipulation & Inbuilt Functions
- 7. Structures and Unions with Arrays
- 8. Linked Lists (Singly, Circular, Doubly)
- 9. Stack (Using Array & Linked List)
- 10. Queue (Simple, Circular, Deque)
- 11. Linear Search & Binary Search
- 12. Sorting Basics: Bubble, Selection, Insertion
- 13. Merge Sort
- 14. Quick Sort
- 15. Counting Sort, Radix Sort, Bucket Sort
- 16. Heap Sort
- 17. Binary Trees & Representations
- 18. Binary Tree Traversals (Pre, In, Post)
- 19. Binary Search Tree (BST)
- 20. AVL Trees (Self-balancing BST)
- 21. Trie (Prefix Tree)
- 22. Segment Tree (Range Queries)
- 23. Fenwick Tree / Binary Indexed Tree (BIT)
- 24. Heap & Priority Queues (Min-Heap, Max-Heap)
- 25. Hashing and Hash Tables
- 26. Disjoint Set Union (Union-Find, Path Compression)
- 27. Sparse Tables
- 28. Sliding Window Technique
- 29. Two Pointers Technique
- 30. Graph Representations (Adjacency Matrix & List)
- 31. BFS and DFS (Traversal & Search)
- 32. Topological Sort (Kahn’s & DFS)
- 33. Shortest Path Algorithms (Dijkstra, Bellman-Ford)
- 34. Minimum Spanning Tree (Kruskal, Prim)
- 35. Cycle Detection in Graphs
- 36. Bridges and Articulation Points
- 37. Greedy Algorithms (Activity Selection, Huffman Coding)
- 38. Backtracking (N-Queens, Sudoku Solver)
- 39. Dynamic Programming (Intro, Memoization, Tabulation)
- 40. Advanced DP (LIS, Knapsack, DP on Trees/Grids)
- 41. Bit Manipulation and XOR Tricks
- 42. Interview Problems from FAANG Companies
- 43. Competitive Coding Patterns
- 44. Building Mini Projects Using DSA (Menu-driven)
- 45. Final Quiz + Problem Sheet (100+ questions)
- 46. Next Steps: Competitive Programming or System Design?
Data Structures and Algorithms in C (DSA)
Category: IT Fundamentals & Programming
This course is designed to help learners master the core concepts of Data Structures and Algorithms (DSA) using the C programming language. Starting from the basics and advancing to complex topics like graphs, dynamic programming, and memory optimization, this course …
Stack (Using Array & Linked List)
📘 Stack (Using Array & Linked List)
A stack is a linear data structure that follows the LIFO (Last In, First Out) principle. The most recent element added is the first one to be removed.
📚 Applications of Stack
- Expression evaluation and conversion (Infix, Prefix, Postfix)
- Backtracking (e.g., maze, puzzles)
- Function call management (Recursion stack)
- Undo/Redo operations
- Syntax parsing in compilers
📌 Basic Stack Operations
- Push: Add element to top of stack
- Pop: Remove top element
- Peek: View top element
- isEmpty: Check if stack is empty
🧱 Stack Implementation Using Array
#define MAX 100 int stack[MAX]; int top = -1; void push(int val) { if (top >= MAX - 1) printf("Stack Overflow\n"); else stack[++top] = val; } int pop() { if (top == -1) { printf("Stack Underflow\n"); return -1; } return stack[top--]; } int peek() { return stack[top]; }
📌 Stack Implementation Using Linked List
struct Node { int data; struct Node* next; }; struct Node* top = NULL; void push(int val) { struct Node* newNode = (struct Node*)malloc(sizeof(struct Node)); newNode->data = val; newNode->next = top; top = newNode; } int pop() { if (top == NULL) { printf("Stack Underflow\n"); return -1; } int val = top->data; struct Node* temp = top; top = top->next; free(temp); return val; }
📊 Array vs Linked List Stack
Feature | Array | Linked List |
---|---|---|
Size | Fixed | Dynamic |
Memory Use | Compact | More (extra pointer) |
Overflow? | Yes | No (unless system runs out of memory) |
🧪 Real-Life Example – Browser History
A browser like UdaanPath’s Web App may use a stack to keep track of visited pages. The back button works by popping the last page visited from the stack.
🧠 Interview Questions
- Implement two stacks in one array
- Check for balanced parentheses using stack
- Convert infix to postfix expression
- Design a stack that supports getMin() in O(1)
📚 Practice Tasks
- Push and Pop elements using both implementations
- Reverse a string using stack
- Check palindrome using stack logic
- Implement a postfix calculator
✅ Summary
- Stack uses LIFO order
- Can be implemented using arrays or linked lists
- Widely used in memory management, parsing, undo features
📤 Coming Next
In the next chapter, we’ll implement the Queue using both Arrays and Linked Lists.