
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Lab 7
(Binary Search Trees)
Exercise 1
Create a class BST using the self-referential class BSTNode having key , data , left , and right data fields. The class BST should have the data field root of type BSTNode and size. It should implement the following methods:
Returns the reference of p’s parent (or null if p is the root).
returns the node that has the maximum key in the binary search tree.( or null if p is null)
Puts the keys of the binary search tree having a root p in the array a in a increasing order. The parameter i is used as an index to the array for recursive calls.
Deletes the leaf nodes from the binary search tree.
Outside the BST class:
Increments stored data in all nodes by 1.
Puts the keys of the sorted array a in the binary search tree b. The parameters l and h are used as an index to the array for recursive calls.