Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Learning Objective: For the student to demonstrate that he or she understands how the recursive binary search algo- rithm works. 4.2 Instructions: This question is

image text in transcribed

Learning Objective: For the student to demonstrate that he or she understands how the recursive binary search algo- rithm works. 4.2 Instructions: This question is not graded, but if you wish, you may include your solution in your word processing document. Problem: Suppose list is an ArrayList of Integers and contains these elements (note that list is sorted in ascending list 2, 3, 5, 10, 16, 24, 32, 48, 96, 120, 240, 360, 800, 1600 h and we call the recursive binary search method, discussed in the lecture notes: int index-recursiveBinarySearch(list, 10, 0, list.sizeO-1); where 10 is the key, 0 is the index of the first element in the range of list that we are searching (this becomes pLow) and list.size)- 1 is the index of the last element in the range of list that we are searching (this becomes pHigh). Trace the method by hand and show the following: (1) The values of pLow and pHigh on entry to each method call; (2) The value of pMiddle that is computed; (3) State which clause of the if-elseif-elseif statement will be executed, i.e., specify if return middle; will be executed, or if return recursiveBinarySearch (pList, pKey, pLow, middle - 1); will be executed, or if return recursiveBinarySearch (pList, pKey, middle 1, pHigh) wll be executed (4) After the method returns, specify the value assigned to inder and the total number of times that recursiveBin- arySearch) was called, including the original call shown above. 4.3 Repeat Exercise 4.2 but this time let pKey be 150. This exercise is graded, so include your trace in the word process- ing document

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

6. Does your speech have a clear and logical structure?

Answered: 1 week ago