subject

Let A[1..n] be a sorted array of n numbers. Here is a code for finding the index of a number x in A. The code uses two indexes, left and right, such that w is between A[left) and A[right]. That is, A[left] < x < A[right]. We start when left = 1 and right = n.

Find(A, x, left, right) {

if (right == left) Return right
Else {mid = [ (right + left)]}
# Note: This is not actually the median value
if x == A[mid) return mid.
If x < A[mid call Find(A, x, left, mid – 1)
Else call Find(A, x, mid, right)

Assume that this code is invoked by calling Find(A, X, 1, n), but x is not one of the keys stored in the array. Write a recursive function that describes the running time in the worst case, and in the best case (the answers are slightly different). Express your answer as logan, where a is a constant you need to specify (Hint: It is not 2).

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 01:00
How can a broadcast station be received through cable and satellite systems?
Answers: 1
question
Computers and Technology, 22.06.2019 07:30
By refraining from constructing a building until they are certain that it will not cause harm to the environment, an organization is adhering to the
Answers: 2
question
Computers and Technology, 23.06.2019 01:30
In deadlock avoidance using banker’s algorithm, what would be the consequence(s) of: (i) a process declaring its maximum need as maximum possible for each resource. in other words, if a resource a has 5 instances, then each process declares its maximum need as 5. (ii) a process declaring its minimum needs as maximum needs. for example, a process may need 2-5 instances of resource a. but it declares its maximum need as 2.
Answers: 3
question
Computers and Technology, 24.06.2019 17:50
Acontact list is a place where you can store a specific contact with other associated information such as a phone number, email address, birthday, etc. write a program that first takes in word pairs that consist of a name and a phone number (both strings). that list is followed by a name, and your program should output that name's phone number.
Answers: 1
You know the right answer?
Let A[1..n] be a sorted array of n numbers. Here is a code for finding the index of a number x in A....
Questions
Questions on the website: 13722362