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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 13:30, baeethtsadia
Asoftware company hired ray, a college graduate to work in their development team. ray is assigned to work in the coding phase of a project. what happens during the coding phase of a software development project? a. the customer receives a working model of the software. b. developers convert the program design into code. c. developers gather requirements directly from the stakeholders. d. testing teams check the product for quality.
Answers: 1
image
Computers and Technology, 22.06.2019 19:30, 710jonathan
The following is an excerpt from a slide presentation. today we will inverse operations solving equations using inverse operations solving inequalities using inverse operations from which part of the presentation does the slide most likely come from? a. introduction b. outline c. body d. conclusion
Answers: 1
image
Computers and Technology, 23.06.2019 12:30, Prettygirlyaya
How is the brightness of oled of the diaplay is controled
Answers: 1
image
Computers and Technology, 23.06.2019 18:30, sawyerfauver
The computers in the sales department did not have enough data storage capacity to contain all the information the department needed to store, and it was taking a long time for team members to access the data they needed. to fix the problem, the technician installed new, larger hard drives on all the computers.
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 in other subjects:

Konu
Mathematics, 30.10.2019 13:31
Konu
Social Studies, 30.10.2019 13:31