You are on page 1of 2

CSCE

156 Lab: Binary Search Trees &


Heaps
Worksheet

Name _________________________________

Activities

1. Create a binary search tree and insert the following elements in the following order:
8, 10, 3, 5, 7, 9, 1, 2, 0
a. What is the depth of the resulting BST?


b. How many leaves are in the resulting BST?


c. Give the preorder traversal of this tree:


d. Give the inorder traversal of this tree:


e. Give the postorder traversal of this tree:


2. Verify that your findElement method works correctly: write code in your demo program to
search for 8, 0, and 42 (unsuccessful search).












3. Create a binary search tree and insert the following elements in the following order:
1, 2, 3, 5, 8, 13, 21, 34, 55, 89
a. What is the depth of the resulting BST?


b. How many leaves are in the resulting BST?


c. Give the preorder traversal of this tree:


d. Give the inorder traversal of this tree:


e. Give the postorder traversal of this tree:


4. Create a binary search tree and insert the following elements in the following order:
8, 4, 2, 6, 12, 10, 9, 1, 0, 5, 3, 14, 7, 11, 15, 13
a. What is the depth of the resulting BST?


b. How many leaves are in the resulting BST?


c. Give the preorder traversal of this tree:


d. Give the inorder traversal of this tree:


e. Give the postorder traversal of this tree:


5. Demonstrate that your heap sort implementation works and get your lab instructor to sign off
on this lab.

Lab Instructor Signature____________________________________

You might also like