ITI 1121. Introduction to Computer Science II

Laboratory 13

Winter 2014

Objectives

Binary search tree

For this part of the laboratory, you will be using the class BinarySearchTree. The class L13P1 contains test cases to help you better understand the questions. Write the following methods inside the class BinarySeachTree.

1 E max()

Returns the largest object stored in this tree. It throws NoSuchElementException if the tree is empty.

2 E min()

Returns the smallest object stored in this tree. It throws NoSuchElementException if the tree is empty.

3 int depth()

Returns the depth of the tree, i.e. the depth of the deepest node of the tree.

4 boolean isTwoTree()

A binary tree is a two-tree if either the tree is empty or all its internal nodes have two children.

File

Last Modified: March 26, 2014