7 Essential Data Structures For Coding Interviews Cheat Sheet
7 Essential Data Structures For Coding Interviews Cheat Sheet
7 Essential Data Structures For Coding Interviews Cheat Sheet
DATA STRUCTURES
Student Grades in GSE 143
Ip Man
3 1993 5. Queue Max Heap Binary Tree
Queues store elements in a First-In, First-Out (FIFO) order, meaning Index: 0
that elements are removed in the order they arrived.
900
1 2
Pros Cons
600 300
Great for breadth-first Limited use cases
search (BFS) 3 4 5 6
compared to other data
550 50 220 80
Efficient add/removal of
items 7 8 9
400 150 10
Queue example
Array Representation
22(key)
12 25
10 20 22 32
Leaf Leaf
8 11 14 34
Application of Heap Data Structures Leaf Leaf Leaf Leaf
Priority queues
Heapsort
Order statistics
A key issue with BST is that they are not self-balancing hence
The key of the left child must be less than or equal to the key of
leading to compromised time-complexity. To mitigate this,
the parent node.
several self-balancing BST variants can be used, such as AVL
The key of the right child must be greater than the key of the
Trees and Red Black Trees.
parent node.
That is, we compare a key (x) stored in a node x with the value to
search y, using the following three conditions:
1. When x is equal to y, x==y, end the search
2. When x is less than or equal to y, x<=y, go to the right child
3. When x is greater than y, x>y, go to the left child