Cpt S 223 Course Overview 1
Course Goals Learn about new/advanced data structures Be able to make design choices on the suitable data structure for different application/problem needs Analyze (objectively) the run-time and memory complexity of algorithms and problem properties Design algorithms for problems, and iteratively improve on the efficiency Express algorithmic language in pseudo-codes (prog language independent) 2
Basic Math Background Summation/Series Geometric, arithmetic, sum of squares, sum of first n ints Proving Techniques By Counterexample By contradiction By contra-positive Induction Recursion Tower of Hanoi Recursive formula from pseudo-codes Tail recursion 3
Algorithmic Notation & Analysis Big-O O() Omega Ω() small-o o() small-omega w() Theta () Worst-case Average-case Best-case Algorithms Lower-bound Upper-bound Tight-bound Optimality 4
Factors for Algorithmic Design Consideration Run-time Space/memory Computational model Suitability to the problem s application domain (contextual relevance) Scalability Guaranteeing correctness Deterministic vs. randomized System considerations: cache, disk, network speeds, etc. 5
Algorithmic Design: An Example The Maximum Subsequence Sum Problem Input: An array A[1..n] of integers Output: Find a stretch with the largest non-negative sum, if one exists O(n 3 ) ==> O(n 2 ) ==> O(n lg n) ==> O(n) 6
Trees Trees Representation Time-efficient Space-efficient Access patterns Depth-first Breadth-first Top-down Bottom-up Traversals Pre-order Post-order In-order Eulerian 7
Search Trees BST AVL Worstcase Avg-case Worst-case Insert O(n) O(lg n) O(lg n) Delete O(n) O(lg n) O(lg n) Find O(n) O(lg n) O(lg n) Height O(n) O(lg n) O(lg n) 8
Search Trees for Disks/Secondary Storage B+ trees Index to the Data Each internal node = 1 disk block Root Internal nodes Leaves Data items stored at leaves Each leaf = 1 disk block M=5 (order of the B+ tree) L=5 (#data items bound for leaves) 9
Priority Queues - Heaps Insert (x) x = DeleteMin() Return the next minimum entry in the queue Alternative: x = DeleteMax() Return the next maximum entry in the queue 10
Heap Main Properties Structure property Heap order property Binary Heap Binomial Heap 11
Binary Heap 12
Binomial Heap B 4 B 3 B 2 B 1 B 0 n = 31 = (1 1 1 1 1) 2 B 3 B 2 13
(Amortized) Run-time Per Operation Insert DeleteMin Merge Binary heap O(lg n) or O(1) O(log n) O(n) Leftist Heap O(log n) O(log n) O(log n) Skew Heap O(log n) O(log n) O(log n) Binomial Heap O(1) O(log n) O(log n) 14
Union-Find Data Structure Disjoint Set operations Two basic operations Find (x) Union (x, y) 15
Heuristics for Union-Find Worst-case run-time for m operations Arbitrary Union, Simple Find Union-by-size, Simple Find Union-by-rank, Simple Find Arbitrary Union, Path compression Find O(m n) O(m log n) O(m log n) O(m log n) Extremely slow Growing function Union-by-rank, Path compression Find O(m Inv.Ackermann(m,n)) = O(m log*n) 16
Algorithm Design Techniques Divide and Conquer Greedy Dynamic Programming 17
Class Reminders COURSE EVALUATIONS Very Important It does matter! By Sunday 12/16 FINALS 8-10 am, Friday, 12/14 18
Thank You!!! 19