Computer scienceLearning library

Data structures and algorithms

Learn to choose data structures and explain algorithm correctness and cost.

Beginner21 chapters14 practice questions3 references
Start coursePractise questions

Get an in-app notice when new lessons or practice are added.

21 chapters across 6 modules

Course chapters

Explore all 21 chapters in any order. Each chapter has learning goals, a practice prompt, and a primary reference; expanded reading pages are linked from their chapter titles.

01 · Reasoning foundations4 chapters
  1. Inputs, outputs, and correctness

    • Write a precise problem contract and identify invariants

    Practice: Specify duplicate handling for a search function.

    Read the primary referenceLesson guide · Ready
  2. Time and space complexity

    • Describe growth rates without treating them as exact timings

    Practice: Compare two ways to detect duplicates.

    Read the primary referenceLesson guide · Ready
  3. Arrays and linked lists

    • Compare contiguous storage, indexing, and structural updates

    Practice: Choose a representation for a queue workload.

    Read the primary referenceLesson guide · Ready
  4. Stacks and queues

    • Apply last-in-first-out and first-in-first-out behavior

    Practice: Check balanced parentheses using a stack.

    Read the primary referenceLesson guide · Ready
02 · Searching and sorting4 chapters
  1. Elementary sorting

    • Trace insertion and selection sort behavior

    Practice: Compare swaps and comparisons on nearly sorted input.

    Read the primary referenceLesson guide · Ready
  2. Merge sort and divide-and-conquer

    • Explain recursive decomposition and merging

    Practice: Implement a merge and test empty inputs.

    Read the primary referenceLesson guide · Ready
  3. Hash tables

    • Explain hashing, collisions, and expected lookup cost

    Practice: Build a frequency table and discuss adversarial cases.

    Read the primary referenceLesson guide · Ready
03 · Trees and graphs4 chapters
  1. Trees and traversal

    • Distinguish tree shape and traversal order

    Practice: Traverse a small directory-like tree.

    Read the primary referenceLesson guide · Ready
  2. Heaps and priority queues

    • Maintain an extremum through a heap invariant

    Practice: Select the next task by priority.

    Read the primary referenceLesson guide · Ready
  3. Graph representations

    • Choose an adjacency representation for a graph workload

    Practice: Model a course-prerequisite graph.

    Read the primary referenceLesson guide · Ready
  4. BFS and DFS

    • Explain visitation state and traversal guarantees

    Practice: Find reachability and an unweighted shortest path.

    Read the primary referenceLesson guide · Ready
04 · Problem-solving patterns4 chapters
  1. Recursion and backtracking

    • Identify base cases and restore state during exploration

    Practice: Generate small combinations without duplicate outputs.

    Read the primary referenceLesson guide · Ready
  2. Greedy reasoning

    • Explain when a local choice needs a correctness argument

    Practice: Test a greedy scheduling rule against counterexamples.

    Read the primary referenceLesson guide · Ready
  3. Dynamic programming

    • Identify repeated subproblems and define state transitions

    Practice: Solve a small counting problem with memoization.

    Read the primary referenceLesson guide · Ready
  4. Mini project: route explorer

    • Combine graph modeling, search, and complexity analysis

    Practice: Build a tiny path-finding tool with a correctness explanation.

    Read the primary referenceLesson guide · Ready
05 · Algorithmic extensions4 chapters
  1. Shortest paths with weights

    • Explain why an unweighted traversal is insufficient for general weights

    Practice: Compare path choices on a small positive-weight graph.

    Read the primary referenceLesson guide · Ready
  2. Topological ordering

    • Connect dependency ordering to acyclic directed graphs

    Practice: Order a small curriculum prerequisite graph and detect a cycle.

    Read the primary referenceLesson guide · Ready
  3. Union-find

    • Use disjoint-set operations to track connectivity

    Practice: Process a sequence of connections and answer component-membership queries.

    Read the primary referenceLesson guide · Ready
  4. Property-based reasoning

    • State properties that should hold across many inputs

    Practice: Design invariants for a sorting implementation and seek counterexamples.

    Read the primary referenceLesson guide · Ready
06 · Further foundations and worked reasoning1 chapter
  1. Cost and invariants

    Use a small search problem to connect correctness with growing input size.

    • State an invariant and a cost model before choosing an implementation

    Practice: Compare two search strategies and trace the invariant on empty and nonempty inputs.

    Read the primary referenceExpanded reading · Ready

Learn it. Check it. Try again.

14 original questions with worked explanations and source references. Filter by difficulty, revisit mistakes, and save your attempt as you go.

Open Data structures and algorithms practice

Books & references

Free reading at the publisher or author’s site. External materials keep their own licenses.