Code in Java
Using the binary search tree (BST) data structure, we can sort a sequence of n elements by first calling aninsertion procedure for n times to maintain a BST, and then performing an Inorder-Tree-Walk on theBST to output the elements in sorted order.
In this programming assignment, you will implement in Java this sorting algorithm using BST, by usingthe improved insertion procedure. Note that each node of a BST is an object containing four attributes:key (for the value of an element), lef t (for its left child), right (for its right child), and p (for its parent).Please add a static counter to track the number of key comparisons made by your algorithm. Your programwill output the following1. The size of the input array,2. The input array,3. The list of array elements after sorting, and4. The number of key comparisons made.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here