CS113 Lecture Topics (after Midterm) Oct 29: Roberts 12, 17.3; Standish 6, 13 Sorting and Algorithmic Efficiency What is Sorting? What is an Algorithm? Selection Sort Big O Intro to MergeSort Oct 31: Recursion pseudo-code and intuition for MergeSort easier recursive examples factorial fibonacci numbers wrapper functions string reversal (printing a string backwards) palindromes types of recursive decomposition left half and right half [merge sort] first and rest [factorial, string reversal] last and all but last [bad algorithm for string reversal] outside and middle [palindrome] Nov 5: Recursion binary search in sorted array towers of hanoi Big O linear, quadratic, logrithmic and exponential growth rates Nov 7: Sorting QuickSort worst case: O(n*n) ave case: O(n log n) can choose pivot in ways which improve performance Big O, Big Omega, Big Theta O(n log n) is best for comparison-based sorting BigOmega(n log n) compares required Radix sort O(n) algorithm limited applicability Insertion sort O(n*n) in general performs well on nearly sorted array Nov 12: Table ADT Interface Linear implementations Sorted/unsroted array, sorted/unsorted linked list Performance Trees basic definitions/vocab better performance for table ADT how do we implement it? Nov 14: Binary Search Trees table.h finding things in a BST Nov 19: BST Implementation did discussed --- --------- New() [Free()] Retrive() [Update()] Traverse() [Visit()] Insert() [Delete()] Nov 21: Improving tree performance Shape: AVL trees definition of AVL property examples how to insert analysis (showing depth is at most O(log n)) Tree Structure: 2-3 trees Other things to do with trees Heaps & Priority Queues Def. of heap: shape and organization inserting items into a heap removing the largest item from a heap Sorting: put things in and read them back out TreeSort (use BST or AVL-BST) HeapSort (use a heap) Nov 26: Hashing: mapping a bunch of keys directly onto an array Inevitable collisions Special considerations for delete and enumerate Resolving collisions with linear probing; clustering Double hashing and permissible decrement rates Performance: If table is half-empty, Most operations are O(1) except for enumerate, which is O(n log n) and init, O(n) Makefiles: targets, dependencies, quirks, implicit rules Nov 28: No class: Thanksgiving Recess Dec 3: Graphs Definitions: vertex, node, edge, augmented graph (labeled graph), weight (of graph, of edge), directed, undirected, successor, predecessor, path, cycle, simple cycle, DAG (directed acyclic graph), connected, weakly connected, strongly connected, connected component, adjacency set, in degree, out degree Representations: adjacency lists, adjacency matrix advantages/disadvantages Traversal Recursive Stack Queue depth-first/breadth first Dec 5: Graphs Spanning Trees min spanning tree algorithm (Prim's algorithm) Shortest Distance Dijkstra's algorithm Topological Order definition and algorithm Greedy Algorithms Dec 10: Graphs and hard problems Dec 17: Final Exam (9 am)