What is a data structure?
A data structure defines how values are arranged and accessed. Choosing one affects the work needed to find, insert or remove an item. A visualization helps reveal the hidden operations: shifting array elements, following linked-list references or updating a stack.
The interactive classroom supports examples in C, C++, Python, Java, JavaScript and C#, with multilingual interface options. Open the data structures visualizer →
Arrays: indexed positions
An array keeps values in an order and permits direct access by index. An index such as 2 identifies the third element. Reading an existing element by index is typically O(1); inserting within a contiguous array may require shifting later elements, giving O(n) work.
Try an array example, then change the index and watch which value is highlighted.
Linked lists: connected nodes
A linked list stores nodes that point to other nodes. You follow links from the head to reach a later element. Given only the head, finding the last node requires walking through the list, usually O(n) steps.
Compare following node references with looking up an array index.
Stacks: last in, first out
A stack places new elements on top with push and removes the top element with pop. Imagine a pile of plates: the last plate placed on top is normally removed first.
Predict which item will be removed after pushing A, B and C.
Queues: first in, first out
A queue accepts new items at the back and removes items from the front. A line of people is a useful analogy: whoever enters first is served first, assuming no priority rules change the order.
Trace enqueue and dequeue operations and compare them with a stack.
Trees and traversal
Trees connect parent nodes to child nodes. In a binary tree, each node has at most two children. Traversal means visiting nodes in a defined order, such as preorder or breadth-first order.
Watch how the chosen traversal changes which node is visited next.
Hash tables and lookup
A hash table computes a bucket from a key. Different keys can map to the same bucket, causing a collision. Lookup is often fast on average, but its performance depends on the hashing strategy, table size and collision handling.
Explore the bucket display to see keys placed into a hash structure.