CS 2223 Apr 30 2018
Expected reading:
Daily Exercise:
Classical selection:
Beethoven:
Symphony No. 9 (1824)
Musical Selection:
Train: Drops of Jupiter (2001)
"The time has come,"
the Walrus said, "To talk of many things:
Of shoes–and ships–
and sealing-wax–
Of cabbages–and kings–
And why the sea is boiling hot–
And whether pigs have wings."
Lewis Carroll
1 Final Preparations
1.1 Data Structures
You are assumed to know the following basic structures:
Arrays
Linked Lists
You know when you should use these structures, and the implication of accessing aggregate data when stored in these structures.
You know about access performance in unordered arrays and linked lists.
Sample Question: You can locate the maximum value in an array of N elements in N-1 comparisons. Now assume you want to find the smallest and the largest value in the same array. What is the lower bound on the number of comparisons you need to make (i.e., the best case)? What is the upper bound on the number of comparisons you need to make (i.e., the worst case)? Can you provide sample instance problems with four elements to cover both these cases?
With linked lists, we saw how they were useful for storing loosely structured collections of values. They are used to implement Bag types, when there is no need to search through, but only retrieve all values in the Bag.
You have seen linked lists as they effectively implement a queue by maintaining two separate pointers, first and last.
Sample Question: Explain how to use a linked list to implement the stack data type.
1.2 Types
You should be well-versed in the basic data types used in this course. This includes:
Bag
Sample Question: It is possible to add a min() operation to the Bag type with performance of O(1) in worst case. How would you do it?
Stack
Sample Question: In Java it is not possible to resize an array of size N; rather you must create a new one (with a size > N) and manually copy the N element into the new array. With this in mind, how is it possible that an array-based implementation of Stack can still guarantee O(1) constant performance on the push operation?
Queue
Priority Queue with Heap (either MIN- or MAX- variety
Sample Question: Why does HeapSort use a MAX-PQ structure instead of a MIN-PQ structure?
Binary Search Tree
Balanced Binary Search Tree – AVL variety
Sample Question: You are given an AVL tree that contains 15 unique values. Compute the maximum height of the tree, that is the greatest distance from any leaf node to the root, that still guarantees the AVL property.
Separate Chaining Hash Symbol Table
Sample Question: How can Symbol table provide average-case expected performance of Θ(1) for search, insert and delete? What is the classification of the worst case for these same operations?
Indexed Priority Queue with Heap Supporting DecreaseKey
Undirected Graph
Sample Question: given an undirected graph G, find all pairs of mirror vertices, that is, two vertices u and v such that the vertices adjacent to u are exactly the same as the vertices adjacent to v. What is the worst case performance of your algorithm?
Directed Graph
Sample Question: Does the mirror vertex question change if the graph is a directed graph? If so, why? if not, why?
Directed Weighted Graph
These types all have common operations as well as specific ones. For example, priority queue and binary search tree both support a deleteMin operation.
Sample Question: How does a Min Priority Queue support
decreaseKey operation?
And why is it hard to envision
adding an increaseKey operations?
Sample Question: You are given a connected undirected graph with an even number of vertices, V, and an even number of edges, E. This graph can be split into two graphs G1 and G2, each of which contains half of the vertices and have of the edges from the original graph. True or false? If false, provide counter example. If true, explain your reasoning.
1.3 Performance classifications
We finally introduced the Big O notation as a means to classify the order of growth of an algorithm. This provided the finishing touches on the performnance analysis that we conducted throughout the term.
You should be able to reflect on the performance families we have seen:
O(1) constant
O(log N) logarithmic
O(N) linear
O(N log N) linearithmic
O(N2) squared
O(N3) cubic
O(Nk) polynomial
O(kN) exponential
Sample Question: You are given a recurrence equation T(n) that is used to estimate the running time performance of an algorithm. You are told that T(N) = 2*T(N/3) + N/3. What is the overall classification using the above families of T(N)?
1.4 Algorithm Families
We discussed a number of thematically related algorithms:
Sorting arrays of unordered elements. This includes InsertionSort, SelectionSort, MergeSort, QuickSort and finally CountingSort
Searching for values in collections
Exploring Graph structures to validate properties
Computing shortest path over weighted graphs
Given a undirected, connected graph, generate a subset graph H that (a) is connected; (b) contains the same vertices; and (c) contains a subset of the edges of G. What is the running time/performance of your algorithm?
1.5 Course Evaluations
I will be handing out the course evaluations at the end of class today, say final ten minutes.
1.6 Version : 2018/04/22
(c) 2018, George Heineman