Question: import java.util.*; public class PoD { //============================================================================= /** * Tries to find an object within the binary tree and * returns true if found and

 import java.util.*; public class PoD { //============================================================================= /** * Tries tofind an object within the binary tree and * returns true iffound and false if not * * @param obj Comparable to searchfor in tree * @param tree BinaryTree of interest * @return boolean

import java.util.*; public class PoD { //============================================================================= /**  * Tries to find an object within the binary tree and  * returns true if found and false if not  *  * @param obj Comparable to search for in tree  * @param tree BinaryTree of interest  * @return boolean value true if object is found, false if not  */   public static boolean findValue(Comparable value, BinaryTree tree) { } //============================================================================= public static void main(String[] args) { Scanner in = new Scanner(System.in); Comparable value = in.next(); BinaryTree newTree = buildTree(in); boolean foundItem = findValue(value, newTree); if (foundItem) { System.out.println("Found " + value); } else { System.out.println("Could not find " + value); } in.close(); System.out.print("END OF OUTPUT"); } public static BinaryTree buildTree(Scanner in) { String data = in.next(); BinaryTree left = null; BinaryTree right = null; if (data.equals("null")) { return null;} if (!in.next().equals("(")) { System.out.println("BAD INPUT: (L"); } left = buildTree(in); right = buildTree(in); if (!in.next().equals(")")) { System.out.println("BAD INPUT: R)"); } return new BinaryTree(data, left, right); } }

Today you are going to search through a binary search tree to find out if it contains a specified value Details Download the ZIP files named FilesNeeded.zip for use in IntelliJ. When you are happy with your solution, upload the files into the src folder and run. You are going to finish off PoD.java to finish the findValue method Input The main method (already completed) creates a binary tree and passes a Comparable object to search for and the binary tree to search to the method findValue. Processing You are going to complete the details of findValue method. Details of each method and their expected parameters are described in the Javadoc comments preceding it. The method should return true if the value is found within the binary tree, and return false if not. Output Output will be handled by the main method based on the value you return. Examples Sample binary tree (created from samplelnput.in)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!