



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
Main points of this exam paper are: Integer Keys, Array Representation, Complete Binary, Binary Tree, Each Node, Complete K-Ary, Ary Trees, Storing Complete, Probe Function, Table Implementation
Typology: Exams
1 / 5
This page cannot be seen from the preview
Don't miss anything!
CS61B Midterm 2 Fall 1997
(2 points) Given the following BST, show its value after deleting 95.
(2 points) Given a BST, there are some keys that, if inserted will increase the height of the tree. For the BST below, list all the integer keys (distinct from those already in the tree) for which this is true. If no such keys exist, explain why not. (Each key should increase the height if inserted alone, not with other keys.)
(4 points) For a given set of keys there are many possible BSTs. Right and left rotations (as defined for Red-Black trees), produce legal BSTs from others. For the BST given below, give another BST with the same keys that CANNOT be formed by performing a sequence of left and right rotations on T. If no such tree exists, explain why not.
(2 points) Given the following Red-Black tree, show its value after inserting the key 29. (Mark the red nodes with an "R" and black nodes with "B" and show the black nulls at the leaves as in your homework assignment.
(2 points) Show the value of the following heap after performing one remove() operation.
Fill in answer above (leaving unused elements blank).
a) Give a formula for finding the jth child of node i in such a tree.
lookupByKey2(String) -- takes only a String key to lookup by k
deleteByKey1(int) -- delete by k
deleteByKey2(String) -- which takes a String key.
All of these operations should work in O(1) time. Give a 1 sentence description of your data structure and draw a picture of it. Your picture should contain at least one stored object with fields k1 and k2.
class TreeNode { left TreeNode; right TreeNode; Object data }
void rotateRightOnLeftChild (TreeNode p) {