HI Could you please help with the following question: I need to…
Question Answered step-by-step HI Could you please help with the following question: I need to… HI Could you please help with the following question: I need to revise the code and add Preorder traversal, Post order traversal ad search Functionality for the following code: class BST { private Node root; class Node { int val; Node left, right; public Node(int value) { val = value; left =null; right = null; } } public BST(int rootValue) { root = new Node(rootValue); } private Node insert(Node root,int value) { if (root == null) { root = new Node(value); return root; } if (value < root.val) root.left = insert(root.left, value); else if (value > root.val) root.right = insert(root.right, value); return root; } void inorderTraversal(Node root) { if (root != null) { inorderTraversal(root.left); // LEFT VALUE System.out.println(root.val); inorderTraversal(root.right); // RIGHT VALUE } } public static void main(String[] args) { BST tree = new BST(5); tree.insert(tree.root,2); tree.insert(tree.root,7); tree.insert(tree.root,10); tree.insert(tree.root,4); tree.insert(tree.root,1); tree.inorderTraversal(tree.root); } } Search for java should include : int n or Node (n)private boolean search(int n){//return true or false if a node contains the value n } Computer Science Engineering & Technology Java Programming CSCE JAVA Share QuestionEmailCopy link Comments (0)


