• Your code should be well commented:
Add your name and email address at the beginning of each .java file.
Write comments within your code when needed.
You must use Javadoc comments for your classes and methods.
In each method’s Javadoc header, include its running time.
• Before submitting your assignment you must zip all your files.
The ZIP file must have the naming convention LastnameFirstname-PA2.zip
• Submit your assignment on LATTE using the assignment submission link.
• You may only use data structures that you implement yourself.
You may not use arrays.
Your data structure should not have hardcoded data types. You should use generics.
The Secret Message
You are a secret agent working for the infamous Brandeis Spy Network.
You’ve received a secret message from your leader, the Professor, in the format of insert statements into an AVL binary search tree.
Your mission is to implement a structure that will perform the specified insertions, so that you can print the postorder traversal of the final, balanced tree, and read the secret message.
You must implement an AVL Binary Search Tree in which each node stores a value. The structure of the tree should be determined by the natural ordering of the values. Natural ordering is when a series of elements are sorted automatically according to their compareTo()method. Thus, your data structure should be of type:
BinarySearchTree<E extends Comparable<E>>.
The insertions in the secret message will be of type DataElement<String>, but you should use generics so that a user can instantiate your tree with any type that extends Comparable.
Besides implementing the following methods, implement any helper methods necessary for your program.
hasLeft( ): returns true if the tree has a left child.
hasRight( ): returns true is the tree has a right child.
isLeaf( ): returns true if the tree is a leaf (has no children).
isEmpty( ): returns true if the tree is empty (doesn’t have a root).
isRoot( ): returns true if the tree has no parent.
isLeftChild( ): returns true if the tree is a left child of its parent.
isRightChild( ): returns true if the tree is a right child of its parent.
hasParent( ): returns true if the tree has a parent.
findNode(E e): returns the node that contains e, or null.
findMin( ): returns the node with the minimum value in the tree.
findSuccessor( ): returns the node that is the successor to the current node.
本网站支持淘宝 支付宝 微信支付 paypal等等交易。如果不放心可以用淘宝交易！
E-mail: [email protected] 微信:itcsdx