CS 127
Midterm 2
Ondich
Due ON PAPER 11:10 AM Monday, March 5, 2001

For this exam, you may use your textbook and a language reference, my sample code, your own programs and notes, and divine guidance should any be available to you. You may not use other books, web pages, or code. If you get stuck, talk to me, but please don't talk to anyone else (not even Jeremy Carr or the lab assistants) about the exam. You may discuss syntax and system problems with Jeremy or the lab assistants, but you must tell them that you are working on an exam.

  1. (12 points) For each of the following scenarios, recommend a data structure. Briefly justify your recommendation.

  2. (12 points) Suppose you have a file consisting of a list of names and their test scores, like so:

    
    	Norman       92
    	Felicity     84
    	Quentin      9
    	Alice        92
    
    	etc.
    

    You may assume that no two lines have the same name, but that scores may be duplicated.

  3. (8 points) Consider the following AVL tree, called T1, whose nodes contain letters of the alphabet:

    
    	Q
    	J U
    	D L S V
    	C H - M - T - X
    	A - E I - - - - - - - - - - - -
    

    (In this representation of a tree, I have written each row of the tree from left to right, with a "-" wherever there is no node. So Q is the root, the children of U are S and V, and V has a right child X but no left child.)

  4. (6 points) Start with the tree T1 from the previous problem, but this time treat it as an ordinary binary search tree (not an AVL tree). Show the tree that results when you delete the root from T1 using the algorithm in section 4.3.4 of your textbook.

  5. (4 points) What is the largest number of edges in a graph with N nodes, given that at most one edge can connect any pair of nodes, and that no edge can connect a node to itself?

  6. (12 points) Consider a graph G with 9 nodes numbered 0 through 8, whose edge set is {(0,8), (0,1), (0,2), (1,3), (2,3), (2,4), (6,8), (5,6), (5,7), (3,7)}.

  7. (2 points) Please recommend a book for me to read.

  8. (6 points) Consider the max heap H1:

    
    	9
    	4 7
    	3 0 6 5
    	2 - - - - - - -
    

  9. (6 points) What is the worst-case complexity (in big-oh notation) of: