Skip to main content

๐Ÿ“Š 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โ€‹

  1. Read the concept page and understand the complexity table.
  2. Type out and run the canonical implementation (learn by doing).
  3. Solve 10 problems of increasing difficulty for each pattern.
  4. 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.

DSA Complexity Cheat Sheet 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.


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:

  1. Foundations โ€” build fluency with basic programming and math for algorithmic thinking.
  2. Core Data โ€” learn how strings, sorting, and hashing power almost every problem.
  3. Core Techniques โ€” the reusable patterns interviewers love (two pointers, sliding window, binary search).
  4. Linear Structures โ€” model order and access patterns with stacks, queues, lists, and heaps.
  5. Hierarchical & Graphs โ€” traverse and reason over trees and graphs.
  6. Advanced Problem Solving โ€” combine everything with backtracking, DP, greedy, and bit tricks.
  7. 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โ€‹

TopicWhat You'll LearnTypical Complexity
๐Ÿซ School BasicsCore programming constructs & basic algorithmsVaries
๐Ÿ”ข MathGCD, primes, modular arithmetic, combinatoricsO(โˆšn) โ€“ O(n)

๐Ÿ”ค Arrays, Strings & Sortingโ€‹

TopicWhat You'll LearnTypical Complexity
๐Ÿ”ค StringsPattern matching, two pointers, hashing, KMPO(n) โ€“ O(n+m)
๐Ÿ”ƒ SortingComparison & non-comparison sorts, stabilityO(n log n)
๐Ÿ—บ๏ธ HashingHash maps/sets for O(1) lookupsO(1) avg

๐Ÿ”ง Core Techniquesโ€‹

TopicWhat You'll LearnTypical Complexity
๐ŸŽฏ Two PointersConverging/parallel pointers on arraysO(n)
๐ŸชŸ Sliding WindowFixed/variable windows for subarraysO(n)
โž• Prefix SumO(1) range queries after preprocessingO(1) query
๐Ÿ” Binary SearchSearch sorted spaces & "binary search on answer"O(log n)
๐Ÿ” RecursionDivide & conquer, call stacks, memoizationVaries
๐Ÿ“‰ Kadane's AlgorithmMaximum subarray sumO(n)

๐Ÿงฑ Linear Data Structuresโ€‹

TopicWhat You'll LearnTypical Complexity
๐Ÿฅž StackLIFO, expression parsing, DFSO(1) push/pop
๐Ÿšถ QueueFIFO, BFS, schedulingO(1) enqueue/dequeue
๐Ÿ”— Linked ListPointers, reversal, cycle detectionO(n)
โ›ฐ๏ธ HeapPriority queues, Top-K, heapsortO(log n)
๐Ÿ“ Monotonic StackNext greater/smaller elementO(n)

๐ŸŒณ Non-Linear Data Structuresโ€‹

TopicWhat You'll LearnTypical Complexity
๐Ÿ”ฒ Matrix2D traversal, rotation, spiralO(mยทn)
๐ŸŒณ TreesTraversals, BST, LCA, tree DPO(n)
๐Ÿ•ธ๏ธ GraphsBFS, DFS, shortest paths, MSTO(V+E)

๐Ÿš€ Advanced Problem Solvingโ€‹

TopicWhat You'll LearnTypical Complexity
๐Ÿ”™ BacktrackingExhaustive search with pruningO(bแตˆ)
๐Ÿง  Dynamic ProgrammingOverlapping subproblems, optimal substructureO(n) โ€“ O(nยฒ)
๐Ÿ’ก GreedyLocally optimal choices, exchange argumentO(n log n)
๐Ÿ”ข Bit ManipulationXOR tricks, masks, set-bit countingO(1) โ€“ O(n)

โšก Big-O Quick Referenceโ€‹

ComplexityNameExample
O(1)ConstantHash lookup, array index
O(log n)LogarithmicBinary search, balanced BST
O(n)LinearSingle pass, prefix sum build
O(n log n)LinearithmicMerge sort, heap sort
O(nยฒ)QuadraticNested loops, bubble sort
O(2โฟ)ExponentialNaive recursion (fib), subsets
O(n!)FactorialPermutations, brute-force TSP

See the complexity cheat sheet above for a visual comparison.


๐Ÿงญ Where to Beginโ€‹

Beginner? Start here in order:

  1. School Basics
  2. Math
  3. Strings
  4. Sorting & Hashing

Comfortable with basics? Build pattern fluency:

  1. Two Pointers
  2. Sliding Window
  3. Prefix Sum
  4. Binary Search & Recursion

Interview prep? Master structures and advanced topics:

  1. Stack, Queue, Linked List, Heap
  2. Trees & Graphs
  3. 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