1/37
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Binary Search Tree (BST)
A binary tree where for every node: all values in the left subtree are smaller and all values in the right subtree are larger. This ordering property allows efficient searching.
Heap
A complete binary tree that satisfies the heap property: in a max heap every parent is greater than or equal to its children, and in a min heap every parent is less than or equal to its children.
Difference between BST and Heap
A BST maintains global ordering (left < node < right) enabling efficient searching. A heap only enforces parent-child ordering and is optimized for quickly accessing the minimum or maximum element.
Breadth-First Search (BFS)
A graph traversal algorithm that visits nodes level by level, exploring all neighbors of a node before moving deeper. It uses a queue.
Depth-First Search (DFS)
A graph traversal algorithm that explores as far as possible down one branch before backtracking. It typically uses recursion or a stack.
Difference between BFS and DFS
BFS explores nodes level by level using a queue and finds shortest paths in unweighted graphs. DFS explores deeply along branches using a stack or recursion.
Dijkstra’s Algorithm
A shortest path algorithm that finds the minimum distance from a source vertex to all other vertices in a weighted graph with non-negative edge weights.
Steps of Dijkstra’s Algorithm
Initialize source distance to 0 and others to infinity, repeatedly select the unvisited vertex with the smallest distance, update its neighbors’ distances, and mark the vertex as visited.
Data structure used in Dijkstra’s Algorithm
A priority queue (usually implemented with a min heap) is used to efficiently select the vertex with the smallest temporary distance.
Limitation of Dijkstra’s Algorithm
It does not work correctly with negative edge weights because it assumes once a node's shortest distance is finalized it cannot decrease.
Binary Search Tree search complexity
O(log n) in a balanced BST but O(n) in the worst case if the tree becomes skewed.
Heap main use
Heaps are commonly used to implement priority queues and efficiently retrieve the minimum or maximum element.
Heap property
The rule that in a max heap every parent node is greater than or equal to its children, and in a min heap every parent node is less than or equal to its children.
Complete binary tree
A tree where every level is full except possibly the last, and nodes in the last level are filled from left to right.
BFS data structure
BFS uses a queue to keep track of the next nodes to visit.
DFS data structure
DFS uses a stack or recursion to explore deeper paths first.
Time complexity of BFS
O(V + E), where V is the number of vertices and E is the number of edges.
Time complexity of DFS
O(V + E), where V is the number of vertices and E is the number of edges.
Time complexity of Dijkstra (priority queue)
O((V + E) log V)
Heap build complexity
Building a heap from an unsorted array takes O(n) time.
Heapsort worst-case complexity
O(n log n)
Preemptive split in B-trees
A technique where a full node is split before inserting a new key during traversal to maintain B-tree properties.
Minimum keys in a B-tree node
For a B-tree with minimum degree t, each node (except the root) must have at least t−1 keys.
Maximum keys in a B-tree node
For a B-tree with minimum degree t, each node can have at most 2t−1 keys.
Maximum children in a B-tree node
A node in a B-tree can have at most 2t children.
In sparse graphs the best implementation for a graph (relating to search time complexity) is…
...adjacency List
In dense graphs the best implementation for a graph (relating to search time complexity) is…
…adjacency matrix
How MaxHeapify works
Restores the max-heap property for a node. It compares the node with its left and right children, swaps it with the largest child if necessary, and recursively continues this process down the tree until the heap property is satisfied.
How Heapsort works
Sorts an array by first building a max heap from the elements.
Repeatedly swaps the root (largest element) with the last element in the heap, reduces the heap size by one, and calls MaxHeapify to restore the heap property.
This continues until the array is sorted.