Java Programming Exercise 2  Another co-worker emails you and said she developed a recursive version for doing search in a binary search tree. Here’s the code for the function: public boolean searchRecursive(Node current, int searchValue) {       if (current.data == searchValue)             return true;       else if (current == null)             return false;       else if (current.data > searchValue)             return searchRecursive(current.left, searchValue);       else             return searchRecursive(current.right, searchValue);            }   She says that she “keeps getting an error” but unfortunately did not say if it was a compile error or a run-time error (or both). You analyze the code and see there is indeed an error and so you reply with the following: 1. Draw a picture of what a binary search tree would look like after inserting values of 5, 10, 8, 15, 4, 2, and 3 in that order 2. Next, tell her why she gets either a compile time error or run-time error (or both) and what happens when you do search(8) and then when you search(20) 3. Finally, tell her the code change(s) you would make to this code to get it to work properly

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Java Programming

Exercise 2 

Another co-worker emails you and said she developed a recursive version for doing search in a binary search tree. Here’s the code for the function:

public boolean searchRecursive(Node current, int searchValue)

{

      if (current.data == searchValue)

            return true;

      else if (current == null)

            return false;

      else if (current.data > searchValue)

            return searchRecursive(current.left, searchValue);

      else

            return searchRecursive(current.right, searchValue);           

}

 

She says that she “keeps getting an error” but unfortunately did not say if it was a compile error or a run-time error (or both). You analyze the code and see there is indeed an error and so you reply with the following:

1. Draw a picture of what a binary search tree would look like after inserting values of 5, 10, 8, 15, 4, 2, and 3 in that order

2. Next, tell her why she gets either a compile time error or run-time error (or both) and what happens when you do search(8) and then when you search(20)

3. Finally, tell her the code change(s) you would make to this code to get it to work properly

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Concept of memory addresses in pointers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education