CSCI 3300
Spring 2009
Exercises for Quiz 10

These problems use the following type, Node.

struct Node
{
  int item;
  Node* left;
  Node* right;
  Node(int i, Node* L, Node* R)
  {
    item = i;
    left = L;
    right = R;
  }
};

  1. Write a function that writes all of the numbers in a binary search tree in ascending order on the standard output, one number per line. The function takes a parameter of type const Node*, pointing to the tree, and has a void return type.

    Answer

  2. Write a function to return the largest number in a binary search tree. There should be one parameter, of type const Node*, pointing to the tree. Assume that the tree is nonempty.

    Answer

  3. If you insert 62 into the following binary search tree, what tree do you get?

    Answer

  4. If you insert 26 into the following binary search tree, what tree do you get?

    Answer

  5. If you remove 40 from the following binary search tree using the algorithm discussed in class, what binary search tree do you get?

    Answer

  6. If you remove 60 from the following binary search tree using the algorithm discussed in class, what binary search tree do you get?

    Answer

  7. If you insert 27 into the following binary search tree, what tree do you get?

    Answer