๐ DSA Concepts
Learning Objectivesโ
- Build solid intuition for common data structures and algorithmic patterns used in interviews and production.
- Learn to reason about time and space complexity and pick appropriate data structures.
- Gain pattern fluency: two pointers, sliding window, prefix sums, binary search, recursion, DP, greedy.
- Practice problem-solving with worked examples and progressively harder exercises.
Prerequisitesโ
- Comfortable with a programming language (JavaScript/TypeScript recommended)
- Basic math: algebra, modular arithmetic, simple combinatorics
Difficulty Levelโ
- Beginner โ Advanced (topic-dependent)
Estimated Reading Timeโ
Overview: 60โ90 minutes; topic deep-dives: 30โ120 minutes each.
Mental Modelโ
Think in terms of abstractions: arrays provide indexed access, linked lists provide cheap insertion, trees represent hierarchies, graphs represent relationships. Algorithms manipulate these structures; the right combination makes problems tractable.
How to Use this Sectionโ
- Follow the recommended learning path from Foundations โ Core Techniques โ Advanced Problem Solving.
- For interview prep, practice problems by category and then mixed practice under timed conditions.
- For production, focus on algorithmic trade-offs, memory/performance, and robust edge-case handling.
Study Workflowโ
- Read the concept page and understand the complexity table.
- Type out and run the canonical implementation (learn by doing).
- Solve 10 problems of increasing difficulty for each pattern.
- Review and refactor solutions to improve clarity and performance.
One-line summary: A structured, topic-wise roadmap through Data Structures & Algorithms โ from first principles to advanced problem solving โ with visuals, complexity tables, and curated practice.
Big-O cheat sheet โ understand time & space trade-offs across every approach
๐ฏ What Are Data Structures & Algorithms?โ
- Data Structures are ways to organize and store data so it can be accessed and modified efficiently (arrays, linked lists, stacks, queues, trees, graphs, heaps, hash tables).
- Algorithms are step-by-step procedures that operate on that data to solve a problem (searching, sorting, traversal, optimization).
The right data structure paired with the right algorithm is the difference between a program that runs in milliseconds and one that runs in hours. Mastering DSA sharpens your problem-solving, prepares you for coding interviews, and makes you a stronger engineer for real-world systems.
๐ก Complexity first: Every topic below includes a Big-O time/space table. Learn to reason about complexity before optimizing.
๐บ๏ธ Recommended Learning Pathโ
flowchart TD
A["๐ซ Foundations<br/>School Basics ยท Math"] --> B["๐ค Core Data<br/>Strings ยท Sorting ยท Hashing"]
B --> C["๐ง Core Techniques<br/>Two Pointers ยท Sliding Window<br/>Prefix Sum ยท Binary Search ยท Recursion"]
C --> D["๐งฑ Linear Structures<br/>Stack ยท Queue ยท Linked List ยท Heap"]
D --> E["๐ณ Hierarchical & Graphs<br/>Trees ยท Graphs ยท Matrix"]
E --> F["๐ Advanced Problem Solving<br/>Backtracking ยท DP ยท Greedy ยท Bit Manipulation"]
F --> G["๐๏ธ System Design<br/>Scalable systems & fundamentals"]
style A fill:#e3f2fd,stroke:#1976d2
style B fill:#e8f5e9,stroke:#388e3c
style C fill:#fff3e0,stroke:#f57c00
style D fill:#f3e5f5,stroke:#7b1fa2
style E fill:#fce4ec,stroke:#c2185b
style F fill:#ede7f6,stroke:#512da8
style G fill:#e0f2f1,stroke:#00796b
How to progress:
- Foundations โ build fluency with basic programming and math for algorithmic thinking.
- Core Data โ learn how strings, sorting, and hashing power almost every problem.
- Core Techniques โ the reusable patterns interviewers love (two pointers, sliding window, binary search).
- Linear Structures โ model order and access patterns with stacks, queues, lists, and heaps.
- Hierarchical & Graphs โ traverse and reason over trees and graphs.
- Advanced Problem Solving โ combine everything with backtracking, DP, greedy, and bit tricks.
- System Design โ scale your knowledge to real, distributed systems.
๐ Topic Directoryโ
All topics are grouped by category and cross-linked. Each page includes explanations, complexity tables, patterns, worked examples, and practice problems.
๐ซ Foundationsโ
| Topic | What You'll Learn | Typical Complexity |
|---|---|---|
| ๐ซ School Basics | Core programming constructs & basic algorithms | Varies |
| ๐ข Math | GCD, primes, modular arithmetic, combinatorics | O(โn) โ O(n) |
๐ค Arrays, Strings & Sortingโ
| Topic | What You'll Learn | Typical Complexity |
|---|---|---|
| ๐ค Strings | Pattern matching, two pointers, hashing, KMP | O(n) โ O(n+m) |
| ๐ Sorting | Comparison & non-comparison sorts, stability | O(n log n) |
| ๐บ๏ธ Hashing | Hash maps/sets for O(1) lookups | O(1) avg |
๐ง Core Techniquesโ
| Topic | What You'll Learn | Typical Complexity |
|---|---|---|
| ๐ฏ Two Pointers | Converging/parallel pointers on arrays | O(n) |
| ๐ช Sliding Window | Fixed/variable windows for subarrays | O(n) |
| โ Prefix Sum | O(1) range queries after preprocessing | O(1) query |
| ๐ Binary Search | Search sorted spaces & "binary search on answer" | O(log n) |
| ๐ Recursion | Divide & conquer, call stacks, memoization | Varies |
| ๐ Kadane's Algorithm | Maximum subarray sum | O(n) |
๐งฑ Linear Data Structuresโ
| Topic | What You'll Learn | Typical Complexity |
|---|---|---|
| ๐ฅ Stack | LIFO, expression parsing, DFS | O(1) push/pop |
| ๐ถ Queue | FIFO, BFS, scheduling | O(1) enqueue/dequeue |
| ๐ Linked List | Pointers, reversal, cycle detection | O(n) |
| โฐ๏ธ Heap | Priority queues, Top-K, heapsort | O(log n) |
| ๐ Monotonic Stack | Next greater/smaller element | O(n) |
๐ณ Non-Linear Data Structuresโ
| Topic | What You'll Learn | Typical Complexity |
|---|---|---|
| ๐ฒ Matrix | 2D traversal, rotation, spiral | O(mยทn) |
| ๐ณ Trees | Traversals, BST, LCA, tree DP | O(n) |
| ๐ธ๏ธ Graphs | BFS, DFS, shortest paths, MST | O(V+E) |
๐ Advanced Problem Solvingโ
| Topic | What You'll Learn | Typical Complexity |
|---|---|---|
| ๐ Backtracking | Exhaustive search with pruning | O(bแต) |
| ๐ง Dynamic Programming | Overlapping subproblems, optimal substructure | O(n) โ O(nยฒ) |
| ๐ก Greedy | Locally optimal choices, exchange argument | O(n log n) |
| ๐ข Bit Manipulation | XOR tricks, masks, set-bit counting | O(1) โ O(n) |
โก Big-O Quick Referenceโ
| Complexity | Name | Example |
|---|---|---|
| O(1) | Constant | Hash lookup, array index |
| O(log n) | Logarithmic | Binary search, balanced BST |
| O(n) | Linear | Single pass, prefix sum build |
| O(n log n) | Linearithmic | Merge sort, heap sort |
| O(nยฒ) | Quadratic | Nested loops, bubble sort |
| O(2โฟ) | Exponential | Naive recursion (fib), subsets |
| O(n!) | Factorial | Permutations, brute-force TSP |
See the complexity cheat sheet above for a visual comparison.
๐งญ Where to Beginโ
Beginner? Start here in order:
Comfortable with basics? Build pattern fluency:
Interview prep? Master structures and advanced topics:
- Stack, Queue, Linked List, Heap
- Trees & Graphs
- Dynamic Programming, Greedy, Backtracking, Bit Manipulation
๐ฏ How to Use These Docsโ
- Read the concept and study the visual/mermaid diagram.
- Memorize the complexity table โ interviewers always ask.
- Type out the code templates โ don't just read them.
- Solve the practice problems from Easy โ Medium โ Hard.
- Cross-link topics โ most hard problems combine two or more patterns.
Start Learning โ ยท ยฉ sparshjaswal