Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need a help to solve algorithm problem! Suppose that we are to search a list of 700 million items using the Recursive Binary Search

I need a help to solve algorithm problem!

Suppose that we are to search a list of 700 million items using the Recursive Binary Search algorithm. What is the maximum number of comparisons that this algorithm must perform (i.e. the worst case) before finding a given item or concluding that it is not in the list? Please show how you arrived at your solution.

-----------------------------------------------------------------------------

Recursive Binary Search Algorithm

Problem - Determine whether x is in the sorted array S of size n.

Inputs - positive integer n, sorted (nondecreasing order) array of keys S indexed from 1 to n, a key x.

Outputs - location, the location of x in S (0 if x is not is S).

index location (index low, index high)

{

index mid;

if (low>high)

return 0;

else {

mid = [(low + high)/2];

return mid

else if (x < S[mid])

return location (low, mid -1);

else

return location (mid + 1. high);

}

}

-----------------------------------------------------------

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

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

More Books

Students also viewed these Databases questions