11
DSA + algorithms / Beginner → intermediate

Stacks, queues, deques, and hash tables

The core structures behind undo, scheduling, traversal, caching, symbol lookup, and fast membership checks.

stackqueuedequehash-tableunordered_map

01Stack: last in, first out

A stack is useful for undo history, expression parsing, depth-first traversal, call-like workflows, and temporary nested state.

cppStack
std::stack<std::string> undo;
undo.push("rename file");
undo.push("delete row");
std::string latest = undo.top();
undo.pop();

02Queue: first in, first out

Queues are useful when work should be processed in arrival order. Breadth-first search, job processing, print queues, and event pipelines are common examples.

03Hash table

cppKey/value lookup
std::unordered_map<std::string, int> stock;
stock["keyboard"] = 8;
stock["mouse"] = 12;

if (stock.contains("keyboard")) {
    stock["keyboard"] -= 1;
}