<pre>class ConstructAVLTree{ private Node rootNode; public ConstructAVLTree(){ rootNode = null; } private boolean searchElement(int element){ return searchElement(rootNode, element); } private boolean searchElement(Node head, int element){ boolean check = false; while((head != null) && !check){ int headElement = head.element; if (element < headElement){ head = head.leftChild; } else if (element > headElement){ head = head.rightChild; } else{ check = true; break; } check = searchElement(head, element); } return check; } } public class AVLTreeExample { public static void main(String[] args) { Scanner sc= new Scanner(System.in); ConstructAVLTree obj = new ConstructAVLTree(); char choice; int ch = sc.nextInt(); switch(ch){ case 1: System.out.println("Enter integer element to search: "); System.out.println(obj.searchElement(sc.nextInt())); break; } } }
I am making a program that can add, remove elements (stacks and queues-like) and display elements in pre, in and post-order traversal. I tried changing boolean to void and default but didn't work and had more errors than expected. Hopefully someone can help me with this error, thank you.
private boolean searchElement(int element){
searchElement
private
public
Quote:private boolean searchElement(int element){ return searchElement(rootNode, element); }
public boolean searchElement(int element){ return searchElement(rootNode, element); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)