Course: Advanced Data Structures and Algorithms
- Definition: A data structure maintaining a set of items under three operations: Search, Insert, and Delete.
- Real-World Use:
- Compilers: Maintaining a "Symbol Table" of all variable names and their addresses. Spelling errors are caught via search.
- Scope Rules: Variables are inserted when entering a block/function and deleted when going out of scope.
- Reserved Words: Static dictionaries for keywords like
if,while,float.
-
Arrays:
$O(n)$ search/insert/delete due to contiguous memory requirements and shifting. -
Sorted Arrays:
$O(\log n)$ search (Binary Search), but$O(n)$ for shift-heavy insert/delete. -
Linked Lists:
$O(n)$ for everything (no random access). -
Goal:
$O(\log n)$ for all three operations.
-
Nodes: Each node has
data,left,right, andparentpointers. -
Property: For every node
$X$ , all values in$X.left < X.data$ and all values in$X.right > X.data$ . -
Operations:
-
Search: Start at root. Descend left or right based on comparison. Complexity
$O(h)$ (height). -
Insert: Descend till a
nilpointer is found; replacenilwith the new node.
-
Search: Start at root. Descend left or right based on comparison. Complexity
-
The "Skewed Tree" Problem [01:41:40]:
- If data is inserted in sorted order (
$10, 20, 30...$ ), the tree becomes a "linked list" with height$O(n)$ . - This destroys the efficiency gains of the tree structure.
- If data is inserted in sorted order (
-
Introduction: A self-balancing BST that imposes "Red" and "Black" properties on nodes to ensure the height remains
$O(\log n)$ regardless of insertion order. -
Complexity: Guarantees
$O(\log n)$ for Search, Insert, and Delete. - Programming Assignment 2: Students are tasked with implementing a full Red-Black Tree.
-
How Random Access Works:
Address = Base_Address + (Index * Size_of_Type). -
Heap vs. BST [02:06:02]:
-
Heap: Optimized for Max/Min access (Priority Queues). Search is
$O(n)$ because you must check both children. - BST: Optimized for Search/Dictionary operations.
-
Heap: Optimized for Max/Min access (Priority Queues). Search is
- Date: March 8th.
- Portion: Everything taught up to Red-Black Trees (Principles, Incremental/Decremental, D&C, Heaps, Partition, Selection, number theory, BST, RBT).
- Format: Subjective (Long answer). No MCQs.
- Advice:
- Solve CLRS Exercises (short/conceptual) instead of the long "Problems".
- Time management: roughly 2 minutes per point.
- "It's for what is recorded that you are going to be awarded marks."
Key Terms Corrected:
- symbol table -> Symbol Table
- licksicographic -> Lexicographic
- CHAR High int -> char, int
- Rakesh Kumar -> Student Question (Student Name)
- root-black trees -> Rooted Trees
- red-black trees -> Red-Black Trees
- Kormann -> Cormen (CLRS)
- low motor partition -> Lomuto Partition
- decriminal design -> Decremental Design