Self-Review Questions

  1. Given a sequence of numbers:
    11, 6, 8, 19, 4, 13, 5, 17, 43, 49, 16, 31, 32
    1. Draw a binary search tree by inserting the above numbers from left to right

    2. What is the height of the above tree?

    3. Show the two trees that can be resulted after the removal of 19.

  2. Draw a binary tree T such that

  3. The worst-case runtime complexity of a postorder traversal of a BST with n nodes

  4. a)   O(log n)
    b)   O(n)
    c)   O(n * log n)
    d)   O(n2)

  5. Which of the following traversals always gives the sorted sequence of the elements in a BST?

  6. a)   Preorder
    b)   Inorder
    c)   Postorder
    d)   depends on how the elements are inserted

  7. The worst-case runtime complexity of insertion into a BST with n nodes is

  8. a)   O(log n)
    b)   O(n)
    c)   O(n * log n)
    d)   O(n2)

  9. The worst-case runtime complexity of building a BST with n nodes

  10. a)   O(log n)
    b)   O(n)
    c)   O(n * log n)
    d)   O(n2)

  11. The height of a Binary Search Tree with n nodes in the worse case is

  12. a)   O(1)
    b)   O(log n)
    c)   O(n)
    d)   O(n * log n)

  13. In a Binary Search Tree, the largest element must

  14. a)   be the root.
    b)   be a leaf.
    c)   have at least one child.
    d)   have at most one child.

  15. Given an array of comparable data. How would you sort it using a BST? What is the runtime complexity of this sort?