CS 2223 May 02 2022
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 :   2022/  04/  30

CS 2223 May 02 2022

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)

Live Selection: Secret World Live, Peter Gabriel (1994)

1 Final Preparations

HW4 is due today at 6PM. There currently are 39 submissions: please make sure to complete today.

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 11:59PM tomorrow, so don’t forget and try to take care of this survey today.

Currently only 35 students have completed the form (a response rate of just 27%). For the results to be considered significant, the percentage needs to get abou 60%. Please consider filling out this survey when you submit your HW4 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

Well, technically, the day before the midterm, I covered Heaps on Apr 01 2022, however I didn’t complete the discussion in time to assign that material for the midterm, so it is still relevant. Practice using the "Heap In Class Exercise.pptx" you can find in Files | handouts in Canvas.

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. I also include some new ones that I have alluded to, but didn’t have time to discuss:

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). Note that by itself, O(...) is not exclusively meant for worst-case scenarios. It is only a tool to classify the upper bound on some situation.

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

NO MORE daily questions! There are a total of 24 questions, and you can earn credit from up to 20 of them.

1.8 Version : 2022/04/30

(c) 2022, George T. Heineman