



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Problem set for exam 3 of the cs61b course taught by david yelick during spring 2003. The problem set includes various questions related to data structures such as heaps, binary search trees, 2-3-4 trees, asymptotic complexity analysis, graph operations, and transitive closure. Students are required to answer each question within the given time limit and provide answers for various problems. The document does not contain solutions.
Typology: Exams
1 / 5
This page cannot be seen from the preview
Don't miss anything!
CS61B (Yelick) Spring 2003
Version 1
Do not open this booklet until you are told to begin!
There are 20 points on this exam. Read each problem carefully, and avoid spending too much time on any one question.
Problem 0 (1 point, 2 minutes): Identification
Fill out your name, your neighbors’ names, and other information in this grid. You may do this before you are told to begin.
Your name: Your cs61b login: Person to your left: Lab time: Person to your right: Lab TA’s name:
Do not open this booklet until you are told to begin!
Grading: Do not write below this line. The following grid will be used for grading.
Problem 0 1 2 3 4 5 6 7 8 Total Possible 1 2 2 3 1.5 3 1.5 3 3 20 Score
Problem 1: (2 points, 4 minutes) Heaps
Suppose that there are N distinct values in a binary max heap (the maximum is at the top). In an array representation, which positions could be occupied by the 4th^ largest element? List all that apply. Assume the heap index starts at 0.
Answer: __________
Problem 2: (2 points, 4 minutes) BSTs
Consider the BST created by inserting the following characters in the given order into an initially empty BST, where the ordering operation is alphabetical: A E F G B D C
For which of the following insert orders will the same BST be created? List all that produce the same BST.
Answer: __________
Problem 3: (3 points, 8 minutes) 2-3-4 Trees
Part A. Given a 2-3-4 tree (called a (2,4) tree in the book) in which all external/sentinel nodes are at depth 3, what is smallest number of keys the tree may have? (Not counting external nodes, this tree has height 2.)
Answer: __________
Part B. Assume your tree from Part A contains even keys 2-2*N, where N is your answer to Part A. What sequence of 2-3-4 operations, as they are defined in the book and lecture notes, will produce your tree from part A? Your answer should have as few operations as possible.
Answer:
Problem 7: (3 points, 10 minutes) Dijkstra’s Algorithm
Run Dijkstra’s Algorithm on the following graph to compute the shortest path from 0 to 7. At each step show the contents of the distance vector (D in the book and d in the lecture notes) after each vertex is visited. Give the resulting path by listing the edges.
visited vertex
Problem 8: (3 points, 10 minutes) Prim-Jarnik Algorithm
Run the Prim-Jarnik Algorithm on the following graph starting from the vertex 0. Show the vector of best-weights-so-far, which is called the D in the book and d in the lecture notes, after each vertex is visited. At each step indicate which vertex is being visited. Also show the final tree by listing the edges in the tree.
visited vertex