COM 1201 Algorithms and Data Structures 2

Notes for Final Exam --
To be given Wednesday, June 6th, 8am-10am, 102KA (Kariotis)

Spring 2000 -- Professor Futrelle
College of Computer Science, Northeastern U., Boston, MA

(Version of 5/30/00)

The Final Exam will last for two hours. Closed book, no calculators allowed.

I will spend all of Thursday's class, June 1st, reviewing for the Final. Feel free to email me and Jiang Zheng with questions before the exam,,

There will be four questions on the Final, on the topics listed below.

  1. The first question will be a specific one on counting. You will be asked to analyze the number of steps taken by selection sort from the code I will give you on the exam. This question will be very similar to the question 3 on the Midterm, which is appended below. After all the practice you had with for loops in your recent homework, I think you're ready for this.

  2. This will be a (not-to-difficult) question on traversing graphs using the adjacency list representation. As long as you can draw a graph given an adjacency list and vice-versa and understand the basic notion of "traversal" (visiting each node once, in some order) this question should not be hard for you.

  3. This question will be on Selection by partitioning. You will need to draw diagrams of the successive subarrays involved in locating the nth element in an array, e.g., the 10th element in an array of 15 items (keys).

  4. The last question will involve priority queues (PQs) using the heap data structure. In particular, you must show that you can draw diagrams showing insert() and getmax() in a PQ, using both fixUp() and fixDown() as necessary.

Question 3 from the Midterm, similar to question 1 on the Final:

Question 3. Selection Sort: Estimate the number of comparison steps ("<") needed in selection sort, as defined by the code below (from Sedgewick). Assume that a selection(a, 0, N-1) call is made. If you understand how the sort works, you may not need to look at the code at all, you could just work through it with a simple diagram. The outer for loop is simple enough; you need only be sure that you understand how many comparison operations, line 5, are performed in the inner for loop for each step in the outer loop. Add up all these operations to get the total. Hint: You should get a sum of approximately N terms. If you don't know how to perform this sum (you should know!) then add up a number of them and see if the sum is growing like N, NlgN, or N2.

What is the "big Oh" complexity of selection sort, based on your analysis?

 1     void selection(int a[], int l, int r)
 2       { for (int i = l; i < r; i++)
 3           { int min = i;
 4             for (int j = i+1; j <= r; j++)
 5                 if (a[j] < a[min]) min = j;
 6             exch(a[i], a[min]);
 7           }
 8       } 


Go to Syllabus and Calendar page for COM1201

Return to Prof. Futrelle's home page