binary search tree error compliation error
-
this is the binary search tree class as you can see the class is developed using generics the problem coming is in testing methods when i m passing integer as two parameters i m not sure why the error is coming whereas the cast i feel is correct .... * * Variables: root : marks the root of the tree, null if empty * * Inner classes: * Node: implements each linked node. Defined as protected since only * descendant classes need to access it * Variables: key: polymorphic comparable key * item: polymorphic data in the node * left: reference to the left subtree * right: reference to the right subtree * Methods: Node(K thisKey, T thisItem) * Node(K thisKey, T thisItem, Node l, Node r) * * Public methods: boolean isEmpty() * void clear() * boolean find(T item) * void insert(T item) * void printPreOrder() * void printInOrder() * void printPostOrder() * * Input: none * * Output: only for regression testing * * Error handling: none * * Regression testing: a private testing method for each public method * except for find and for insert (since this is * asked for during the prac). */ public class BinarySearchTree<K extends Comparable<K>,T extends Comparable<T>> { // Invariants for the class (and all its descendandts): // (1) the tree is binary: all nodes have at most two children // (2) for every node n, they key at n is greater than the key of any left // descendant, and smaller than the key of any right descendant // (3) Corollary: no key appears twice in the tree protected Node root; protected class Node { protected K key; protected SortedLList<T> item; protected Node left; protected Node right; // Creates a new leaf node of the tree with the appropriate data // // precondition: none new // postcondition: a leaf node object is created with key data thisKey // and item thisItem // Best and worst case: O(1) protected Node(K thisKey, SortedLList<T> thisItem) { key = thisKey; item = thisItem; left = null; right = null;} // Creates a new node of the tree with the appropriate data and pointing // to the given left and right children no
-
this is the binary search tree class as you can see the class is developed using generics the problem coming is in testing methods when i m passing integer as two parameters i m not sure why the error is coming whereas the cast i feel is correct .... * * Variables: root : marks the root of the tree, null if empty * * Inner classes: * Node: implements each linked node. Defined as protected since only * descendant classes need to access it * Variables: key: polymorphic comparable key * item: polymorphic data in the node * left: reference to the left subtree * right: reference to the right subtree * Methods: Node(K thisKey, T thisItem) * Node(K thisKey, T thisItem, Node l, Node r) * * Public methods: boolean isEmpty() * void clear() * boolean find(T item) * void insert(T item) * void printPreOrder() * void printInOrder() * void printPostOrder() * * Input: none * * Output: only for regression testing * * Error handling: none * * Regression testing: a private testing method for each public method * except for find and for insert (since this is * asked for during the prac). */ public class BinarySearchTree<K extends Comparable<K>,T extends Comparable<T>> { // Invariants for the class (and all its descendandts): // (1) the tree is binary: all nodes have at most two children // (2) for every node n, they key at n is greater than the key of any left // descendant, and smaller than the key of any right descendant // (3) Corollary: no key appears twice in the tree protected Node root; protected class Node { protected K key; protected SortedLList<T> item; protected Node left; protected Node right; // Creates a new leaf node of the tree with the appropriate data // // precondition: none new // postcondition: a leaf node object is created with key data thisKey // and item thisItem // Best and worst case: O(1) protected Node(K thisKey, SortedLList<T> thisItem) { key = thisKey; item = thisItem; left = null; right = null;} // Creates a new node of the tree with the appropriate data and pointing // to the given left and right children no
That's a ton of text....What's the error?