Algorithms & Data Structures
Everything below this point in the knowledge base is about what the machine can do. This section is
Everything below this point in the knowledge base is about what the machine can do. This section is
An array is a block of contiguous memory holding equally-sized elements. That one property gives it
A binary search tree is $O(\log n)$ only while it stays short, and nothing in the plain
A data structure is a decision about which operations you want to be cheap. There is no structure
This page is a reference, not a tutorial — each page in this section explains the reasoning behind the
A stack grows and shrinks at one end; a queue adds
A graph is a set of vertices and a set of edges connecting them. That is nearly no structure
A hash table turns a key into an array index by running it through a hash function, then reads or
A priority queue answers one question: what is the most important item right now? A binary
A linked list stores each element in its own node, together with a pointer to the next one. Nothing
A cache with unlimited capacity is just a hash table. The interesting problem
Every structure so far in this section answers its question exactly, at the cost of storing enough
Prefix sums answer range-sum
Stacks and queues are not new storage — they are restrictions on storage. Both hold a sequence,
Containers store collections of objects. The STL provides optimized, well-tested containers for different access patterns and performance needs. Choose the right container for your use case.
A tree is a set of nodes where each node has one parent (except the root) and no cycles. That single
A hash set answers "is this exact string in the set?" and nothing else. It cannot answer "what strings
Some problems never ask what is in a group. They ask only whether two things have ended up in the