CS 215 ­ Fundamentals of Programming II  Fall 2013 ­ Homework 11 20 points Out: November 22, 2013

advertisement
CS 215 ­ Fundamentals of Programming II Fall 2013 ­ Homework 11
20 points
Out: November 22, 2013
Due: December 4, 2013 (Wednesday after Thanksgiving)
1. (8 points) For each sequence of characters, draw the binary search tree (BST) that results after inserting the sequence of characters into an empty BST. Then give the order the nodes are visited when the tree is traversed by in­order, pre­order, and post­order scans.
a) F, L, O, R, I, D, A
b) R, O, T, A, R, Y, C, L, U, B
2. (4 points) Consider the following BST:
50
25
80
20
35
30
27
70
45
33
95
75
47
90
98
93
Re­draw the tree after erasing values 27, 45, and 80.
3. (4 points) Use the integers from 0 to 9 to build a ten­node BST. Draw one example BST for each possible root node value for a tree of depth 4. That is, draw a BST where 0 is the root value, where 1 is the root value, etc. (Recall the definition of the depth of a tree is the maximum depth of any node in the tree.)
4. (4 points) Write a Binary_Search_Tree member function minimum that returns the minimum value in the tree. Note: you are not required to implement this function in a program that runs, but you can if you want to. This function would go in file bst.h from Lecture 33 on November 13.
11/21/2013
Page 1 of 1
D. Hwang
Download