CS 2223 May 11 2021
1 Final Preparations
1.1 Data Structures
1.2 Types
1.3 Since Midterm
1.4 Performance classifications
1.5 Mathematical Analysis
1.5.1 Best-Case and Worst-Case
1.6 Algorithm Families
1.7 Daily Question
1.8 Version :   2021/  05/  13

CS 2223 May 11 2021

Lecture Path: 27
Back Next

Expected reading:
Daily Exercise:
Classical selection: Beethoven: Symphony No. 9 (1824)

Visual Selection:

Musical Selection: Questions, Moody Blues (1970)

Visual Selection: The Scream, Edvard Muchde (1893)

1 Final Preparations

Please take a few minutes before class begins to log into Canvas to complete the course evaluation. I use this information to improve my next course offering. You will have until 10PM May 13th, so don’t forget and try to take care of this survey today.

HW5 is due today at 6PM.

I have updated the git repository to have my solutions for HW1 to HW4. I will upload my HW5 solutions after 6PM tonight.

1.1 Data Structures

"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

You are assumed to know the following basic structures:

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:

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 Since Midterm

Binary Search Trees are central data structure in this course and beyond. Numerous data structures are based on its principles:

Graphs close out the remainder of the class material:

1.4 Performance classifications

We finally introduced the Big O notation as a means to classify the order of growth of a function, which typically represents the run-time performance of an algorithm or the exact number of times an operation executes. 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:

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.5 Mathematical Analysis

We have seen situations where we were concerned about counting the exact number of times an operation executed. Sometimes without knowing the exact input, it is only possible to determine the fewest number of times an operation executed (called the lower bound) or the maximum number of times an operation executed (called the upper bound).

1.5.1 Best-Case and Worst-Case

For BinaryArraySearch for example, given N integers in sorted ascending order in an array, we know that you can find (in the worst case) whether it contains a target integer in no worse than floor(log N) + 1 array inspections.

Note: you could try to claim that you need N array inspections by using a simple for loop, but this would not be "the best of the worst case" algorithms.

Thus to use "Big-Oh" notation O(g(n)) to classify the worst-case performance of Binary Array Search on a problem of size N, we would state that the worst case behavior is O(log N).

For this same problem, the best case is you would find the integer after just a single array inspection. In this case using Ω(g(n)) notation to classify the best-case performance of Binary Array Search on a problem of size N, we would state that best case behavior is Ω(1).

1.6 Algorithm Families

We discussed a number of thematically related algorithms:

Given a directed graph, G, compute an undirected graph H in which an edge (u,v) exists in H if either the directed edge u > v or the directed edge v > u exists in G. What is the running time/performance of your algorithm?

1.7 Daily Question

Final daily question is available today.

If you have any trouble accessing this question, please let me know immediately on Discord.

1.8 Version : 2021/05/13

(c) 2021, George T. Heineman