ineedtostudy.com
Log in Sign up
← Discover

Data structures

Data Structures at a Glance

11 terms · by ineedtostudy · updated 4 hours ago

Sign up or log in to track what you have mastered. You can still study this set as a guest.

Terms in this set

Array
Contiguous, fixed size. O(1) access by index, O(n) insert or delete in the middle.
Dynamic array
Grows by reallocating, usually doubling. O(1) amortised append.
Linked list
Nodes with pointers. O(1) insert or delete given the node, O(n) to find it. No index access.
Stack
Last in, first out. Push and pop are O(1). Call stacks, undo, depth-first search.
Queue
First in, first out. Enqueue and dequeue are O(1). Breadth-first search, job scheduling.
Hash table
Key to value via a hash function. O(1) average lookup, O(n) worst case when everything collides. No ordering.
Binary search tree
Left subtree smaller, right larger. O(log n) when balanced, O(n) when degenerate.
Balanced BST
Rebalances on insert to guarantee O(log n). Red-black trees and AVL trees.
Heap
A complete tree where each parent beats its children. O(1) peek, O(log n) insert and extract. Priority queues.
Graph
Vertices and edges. Adjacency list for sparse graphs, adjacency matrix for dense ones.
Trie
A tree keyed by character prefix. Lookup costs O(length of key) regardless of how many keys are stored.