COP 3530
Assignment 11
Due: 13
th
Nov 2009
Q1 . AVL tree
Start with an empty AVL search tree and insert the following keys in the given
order: 25, 35, 45, 20, 22, 27. Draw the trees following each insertion, and also
after each rotation. Specify the rotation types. You do need to specify the
balancing factors.
Q2. Binary Search Tree
In this problem, you will extend the
BinarySearchTree
class to support
several additional functions. PLEASE put all your solutions in one single java file.
Name this file
MyBinarySearchTree.java.
a)
Implement a new method
check()
, which will check whether the current tree
is a binary search tree or not. For example, if MyBinarySearchTree t equals to:
then t.check() should return true. But if t equals to:
t.check()
should return false.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Documentb)
Implement a new method
removeLarger(int x)
, which will remove all
elements larger than x from a given binarySearchTree. For example, if t equals to:
After calling
t.removeLarger(5)
, t should become
Note that the worst time complexity of your method must be O(n), where n is
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '08
 Davis
 Algorithms, Data Structures, Following, Christopher Nolan, Return statement, Void type, new Integer

Click to edit the document details