Skip to content
QuantMax
QuantMax
  • Overview
  • Curriculum
    • FLUMental maths and numerical fluency
    • COMBCounting and combinatorics
    • PROBProbability
    • GAMEGames, decision theory and puzzles
    • MMMarket making
    • MKTMarkets and products

Practise

  • Question bank
  • Mental arithmetic
  • Market simulator
  • Arbitrage trees
  • Horse racing
  • Bid book
  • Screening tests
  • Mock papers

Reference

  • Formula reference
  • Search

Your record

  • Review queue
  • Progress
  • Leaderboard
  • Profile
  • Invite friends
AccountSend feedback
  1. Formula reference

Data structures and algorithms

7 lessons · 2 equations. Each lesson below gives its formulas and key rules; open the lesson for the full explanation.

Complexity: reading it off, and deriving it

The master theorem

T(n)=a T ⁣(nb)+f(n)T(n) = a\,T\!\left(\tfrac{n}{b}\right) + f(n)T(n)=aT(bn​)+f(n)

Compare f(n)f(n)f(n) with nlog⁡ban^{\log_b a}nlogb​a: whichever dominates gives the answer, and if they match you gain a log⁡n\log nlogn.

Remember

  • Know the four-column table for the standard structures without thinking.

Linear structures: arrays, hash maps and monotonic stacks

Key rules

  • Choose from the access pattern: index, key, order, or ends.
  • Hash maps are O(1)O(1)O(1) average, O(n)O(n)O(n) worst case, and need immutable keys.
  • A hash map trades O(n)O(n)O(n) space to remove a factor of nnn from the time.

Trees and heaps: BSTs, priority queues and range queries

The Fenwick tree’s one trick

query: i←i−(i & −i),update: i←i+(i & −i)\text{query: } i \leftarrow i - (i \,\&\, {-i}), \qquad \text{update: } i \leftarrow i + (i \,\&\, {-i})query: i←i−(i&−i),update: i←i+(i&−i)

A Fenwick (binary indexed) tree stores partial sums in a flat array. Index iii holds the sum of the last i & −ii \,\&\, {-i}i&−i elements up to iii; stripping or adding the lowest set bit walks the O(log⁡n)O(\log n)O(logn) nodes a prefix query or a point update needs.

Remember

  • A BST gives ordered operations; a hash map gives only exact lookup.

Graphs: traversal, shortest paths and union–find

Key rules

  • BFS for minimum hops, DFS for connectivity and ordering.
  • Dijkstra needs non-negative weights; Bellman–Ford handles negatives and finds negative cycles.
  • Negative log rates turn arbitrage into a negative-cycle problem.

Core techniques: binary search on the answer, two pointers, sliding windows

Key rules

  • Binary search needs a monotone predicate, not a sorted array.
  • "Minimum xxx such that it works" is a binary search over the answer.
  • Sliding windows are linear because each index enters and leaves once.

Dynamic programming, and why it is the same as an EV recursion

Key rules

  • State, transition, base cases, evaluation order — in that order, out loud.
  • Memoisation visits only what is reachable; tabulation often reduces the space.
  • An expected-value recursion is a dynamic programme with probabilistic transitions.

Bit manipulation and modular arithmetic

Key rules

  • x & (x−1)x \,\&\, (x-1)x&(x−1) clears the lowest set bit; x & −xx \,\&\, -xx&−x isolates it.
  • XOR is self-inverse, so it cancels everything appearing twice.
  • Addition and multiplication commute with the modulus; division does not.

Detailed formula cards

  • The master theorem

QuantMax · 141 lessons · 1342 questions · c5c0caa

  • Premium
  • Arbitrage trees
  • Horse racing
  • Invite friends
  • Account
  • About QuantMax

Firm names identify publicly reported question patterns and nothing more. QuantMax is not affiliated with, endorsed by, or recruiting for any firm named in the curriculum. Everything you do in lessons and the question bank is kept to your account.