Академический Документы
Профессиональный Документы
Культура Документы
ID: 002885414
Date: 2/21/2018
This shows the implementation of Binary Search tree functions working correctly for the final project.
The sample array is {3, 33, 7, 21, 9, 15, 55, 32, 24}. The inorder() function works correctly as it shows the
correct traversal. The leafHeights() function works correctly as it correctly displays each leaf and their
heights. The NewSearch() function works correctly as it correctly shows if the item is in the BST or if
there is a next greater item, or if it is greater than all the items in the BST.
Part 1:
Pseudocode:
Create array
Void ArrayBalance(int A[], int start, int end, int & count, int temp[])
ArrayBalance(A, start, mid -1, count, temp); // traverse left side of array
// Traverse new array and insert each item into balanced binary search tree
IntBST.insert(temp[i]);
Part 3:
Pseudocode:
Increment height
Part 4:
Pseudocode:
If found = =0, print the number is greater than all the numbers in the binary search tree
Else print found, which is the next largest number in the binary search tree
Running time for NewSearchAux is 0(n) where n is the number of nodes