1/32
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Binary Heap (Min-Heap) Validity
It must be a complete binary tree and satisfy the heap property: parent ≤ children.
Adding to a Binary Heap
Insert at the next open spot, then bubble up to restore the heap property.
Deleting from a Binary Heap (Min-Priority)
Remove the root, replace with the last node, then bubble down to restore order.
Binary Search Tree (BST) Validity
It must follow the BST property: left < root < right.
Adding to a BST
Recursively find the correct spot and insert the value as a leaf.
Deleting from a BST (Min-Priority)
Remove node: Leaf → delete; 1 child → replace with child; 2 children → replace with in-order successor, then delete the successor.
AVL Tree Validity
It must be a BST and balanced, with a balance factor ∈ {–1, 0, 1}.
Adding to an AVL Tree
Insert like in a BST, then rebalance using rotations (LL, RR, LR, RL) if needed.
Deleting from an AVL Tree (Min-Priority)
Delete like in a BST, then rebalance up the path to the root using rotations.
Bubble Sort Method
It repeatedly swaps adjacent elements if they are in the wrong order.
Bubble Sort Time Complexity
Worst & Average: O(n²), Best: O(n).
Bubble Sort Memory Usage
O(1) (in-place).
Is Bubble Sort Stable?
Yes.
Insertion Sort Method
Builds the sorted list one item at a time by inserting into the correct position.
Insertion Sort Time Complexity
Worst & Average: O(n²), Best: O(n).
Insertion Sort Memory Usage
O(1) (in-place).
Is Insertion Sort Stable?
Yes.
Selection Sort Method
Repeatedly selects the smallest element and moves it to the sorted position.
Selection Sort Time Complexity
Worst/Average/Best: O(n²).
Selection Sort Memory Usage
O(1) (in-place).
Is Selection Sort Stable?
No.
Shell Sort Method
Improves insertion sort by comparing and sorting elements far apart (using a gap sequence).
Shell Sort Time Complexity
Worst: O(n²) or better depending on gap, Best: O(n log n).
Shell Sort Memory Usage
O(1) (in-place).
Is Shell Sort Stable?
No.
Quick Sort Method
Divides the array around a pivot and recursively sorts partitions.
Quick Sort Time Complexity
Worst: O(n²), Average/Best: O(n log n).
Quick Sort Memory Usage
O(log n) for recursion stack.
Is Quick Sort Stable?
No.
Merge Sort Method
Splits the array, recursively sorts halves, and merges them.
Merge Sort Time Complexity
All cases: O(n log n).
Merge Sort Memory Usage
O(n) for merging.
Is Merge Sort Stable?
Yes.