Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

QUESTION 3 Consider plist -11.23,4 5, 6,7,8, 9, 10 ) We call recursiveBinarySearch0 to search the list for pKey - 4. During the search, the

image text in transcribed
QUESTION 3 Consider plist -11.23,4 5, 6,7,8, 9, 10 ) We call recursiveBinarySearch0 to search the list for pKey - 4. During the search, the first time that pkey is greater than the element at midle we will make a recursive call passing middle+ 1 and pHigh as the indices for the range of plist to be searched in the recursive call. What will be the values of middie + 1 and pHigh? passing middle + 1 and pHigh as the indices middle + 1 will be 5 and pHigh will be 3 middle + 1 will be 3 and pHigh will be 3 middle + 1 will be 4 and pHigh will be 9 middle + 1 will be 2 and pHigh will be 3 QUESTION 4 Consider list = (4, 2, 7, 3, 5, 13, 11, 8, 6, 2). Suppose we modify the quick sort algorithm so rather than choosing the first element at fromindex as pivot in the partition) method, we choose the last element element at tolndex as pivot. This requires a change to the quick Sort) method: when we make the original call to sort list, we still pass the indices of the first and last elements of list as the arguments to quickSortO-in this example, the call would be quickSort(list, o, 9) but on the subsequent recursive calls, we must pass rromindex and partitionder-1 as arguments to quickSorto-rather than passing fromindex and partitionindex as we would when choosing the first element as pivot we make those changes and then make the original call quicksort(list, , 9) to sort /sr. Since fromIndex is less than tolndex we will call partition(ist, o, 9). After we return from partition()-which returns partitionindex-we recursively call quicksort) twice. The question is: during the first recursive call, what what will be the values of the fromindex and Save All Answ

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

Recommended Textbook for

Marketing Database Analytics

Authors: Andrew D. Banasiewicz

1st Edition

0415657881, 978-0415657884

More Books

Students also viewed these Databases questions

Question

5. How would you describe your typical day at work?

Answered: 1 week ago

Question

7. What qualities do you see as necessary for your line of work?

Answered: 1 week ago