Assignment 4 ADC – Binary Search Tree This homework has a value of 1.5 points. One can find documentation for everything in it by reading chapter 12 of “Introduction to algorithms / Thomas H. Cormen et al.” Write a Java Applet that implements a binary search tree with the following operations: ADD, SEARCH, SORT, PREDECESSOR, SUCCESSOR, and DELETE. The tree is initially empty. a) ADD (or INSERT) – You need to have a button “ADD” and a textbox. When one clicks this button, the number (or key) in the textbox is inserted in the search tree. The first key added in this data structure corresponds to the node number 1. The second corresponds to the node 2, etc. One might use a vector called KEY, so that keyValue = KEY[keyIndex]. b) SEARCH – When this button is clicked, the applet searches for a key (from in a textbox) and outputs its index (if found) or -1 (otherwise). c) SORT – Sorts all the keys in the search tree and prints out the first 10. d) PREDECESOR – given an index of a node, outputs the predecessor node (his index and his key). e) SUCCESOR – given an index of a node, outputs the next node (his index and his key) in the node list. The predecessor and successor are considered with respect to the sorted list of keys. f) DELETE – erases a node from the tree given its index. g) Complexity – One can print out the sorted keys by finding the minimum key and then by making n-1 calls to SUCCESOR (function TREE-SUCCESROR in Cormen). Prove that this algorithm runs in O(n) time. The following data needs to be printed all the time: the number of nodes (n) in the tree (initially 0) the keys for the first 10 nodes (i.e key[0]=23, key[1]=1, key[2]=50) the left node for every node (i.e. left[0]=1, left[1]=NIL,left[2]=NIL) the right nodes (i.e. right[0]=2, right[1]=NIL, right[2]=NIL) Note: Please, use the following subject field in your e-mail when sending the source codes and readme: ADC4 * Group * LAST NAME * first name Deadline: January 10, 2005