Which of the following are binary search trees?
Write the values printed by an in-order traversal of each of the following BSTs. What do you notice about the resulting sequences?
Draw the binary tree resulting from the following sequence of insertions:
= new BST();
t .insert(10)
t.insert(15)
t.insert(16)
t.insert(8)
t.insert(16)
t.insert(9)
t.insert(11)
t.insert(-1) t
Draw the binary tree resulting from the following sequence of insertions:
= new BST();
t .insert(-1)
t.insert(8)
t.insert(9)
t.insert(10)
t.insert(11)
t.insert(15)
t.insert(16)
t.insert(16) t
Implement the minimum
method in the following BST class, which finds the smallest value in a BST:
/** BST: a binary tree, in which:
* - all values in left are < value
* - all values in right are > value
* - left and right are BSTs */
public class BST {
int value;
;
BST left;
BST right
/** Returns the minimum value in BST n.
* pre: n is not null */
public static int minimum(Node n) {
// your code here
}
}
remove(9)
remove(4)
remove(10)