Data Structure Visualizer
Animated stack, queue, linked list, and binary search tree — push, pop, insert, delete, and search, with the traversed path and Big O cost shown live.
Push / Pop — O(1)
Push adds to the top, pop removes from the top — both O(1).
Enqueue adds to the rear, dequeue removes from the front — both O(1).
Insert at head is O(1). Insert at tail or delete by value is O(n) without a tail pointer.
Insert, delete, or search — the traversed path lights up in blue.
Data Structure Visualizer guide
Developer Tool
Reading that a binary search tree insert is O(log n) is one thing; watching the comparison path narrow from root to leaf, three hops instead of ten, is what makes it stick. This tool animates four of the structures that show up constantly in interviews and coursework — stack, queue, singly linked list, and binary search tree — so every push, pop, insert, and delete is something you watch happen rather than something you take on faith. Each operation reports its own cost, so the visual and the complexity number reinforce each other instead of living in separate places.
What each structure is actually for
A stack is last-in-first-out — the last item pushed is the first one popped, which is why it models undo history, call stacks, and matching brackets naturally. A queue is first-in-first-out, the right shape for task scheduling, print queues, or breadth-first traversal order. Both give O(1) insert and remove because neither one ever needs to shift or search through existing elements.
A singly linked list trades the O(1) random access of an array for O(1) insertion at the head — no other elements move, unlike an array where inserting at the front means shifting everything else over. A binary search tree keeps elements ordered so search, insert, and delete can all run in O(h), where h is the tree height — O(log n) once balanced, but O(n) in the worst case if insertions happen to walk it into a straight line.
Why the binary search tree needs a diagram
Deleting from a BST is the one operation on this page that is genuinely easier to understand visually than in words: a leaf just disappears, a node with one child is replaced by that child, but a node with two children has to be replaced by its in-order successor — the smallest value in its right subtree — to keep the ordering property intact. Try deleting the root of the tree here and watch which node slides into its place; that single animation covers a case that trips up a lot of written explanations.
Insert and search both highlight the exact comparison path in blue, so "O(h) comparisons" stops being an abstract bound and becomes a specific, countable number of hops you just watched happen.
Related tools
Explore these related tools to complete your workflow faster.