CPSC 221H: Data Structures & Algorithms
Information and Review Questions for Exam I
Spring 2009


General Information

The first exam will be on Tuesday February 24. It will cover material from Chapters 4, 5, 6, and 7, in the text. It will be a closed book exam (no notes, books, or neighbors) except you will be allowed a one page (8.5x11), two side cheat sheet which must be turned in with the exam. There will be 5 questions, each worth 20 points, for a total of 100 points. Remember to show your work - partial credit will be given.


Material

All of the following are considered to be fair game:


Review Questions

Below are some suggested review exercises/problems for the exam. It is strongly recommended that you be able to do all of these problems. Solutions will not be handed out. Finally, be sure to check your email -- clarifications and/or explanations will be mailed to the class if needed.

  1. Study Homeworks 1-4, Quizzes 1-4, and the in class assignments; variations of some of these questions will appear on the exam.

  2. Know the space usage and the running times for performing operations on all of the data structures we have studied in class. Be able to answer questions of the following form for all combinations of ADTs and implementations (there are just a few shown below):

  3. Describe, in pseudo-code with accompanying pictures, how to swap two nodes x and y in a singly linked list L given pointers only to x and to y. Repeat this exercise for the case when L is a doubly linked list. What are the running times of each of these functions in terms of n, the number of nodes in L?

  4. Answer the following questions about binary trees.

  5. Design an algorithm based on the Priority Queue ADT, implemented with a heap (which is in turn implemented with a vector-based structure for binary trees), where the element with the maximum key is stored at the root of the heap (often called a max-heap). The algorithm should find the kth largest element in a list of n elements. The only (non-trivial) operations your algorithm should perform are: Describe your algorithm in pseudo code and words, discuss its correctness, and analyze its complexity.