This exercise refers to the binary search algorithm given below. def Binary Search (a, t) : L=0 R = len(a) - 1 while L <= R: m = floor((L+R)/2) if a[m] t: R=m-1 else: return m return -1 Suppose our list of increasing integers is shown in the table below 23467101215 Suppose we conduct the binary search algorithm on this list where we search for 12. (a) In the language of the algorithm above, enter the correct values for the following variables for this particular search (where n is the length of the list): n= ||a[1] = ||a[3] = (b) After the first iteration of the while loop, what are the values of the following variables? L= R= im = ". (c) Intuitively, after the first iteration of the while loop, we have cut down our search to a set S of roughly half of the original numbers on the list. Check the numbers that are in the set S after the first iteration of the while loop: S has the following elements: □ A. 6 B. 4 C. 10 Suppose we conduct the binary search algorithm on this list where we search for 12. (a) In the language of the algorithm above, enter the correct values for the following variables for this particular search (where n is the length of the list): t = n = ||a[1] = ||a[3] = (b) After the first iteration of the while loop, what are the values of the following variables? L = R= m= (c) Intuitively, after the first iteration of the while loop, we have cut down our search to a set S of roughly half of the original numbers on the list. Check the numbers that are in the set S after the first iteration of the while loop: S has the following elements: □ A. 6 B. 4 C. 10 D. 3 E. 15 E 12 G. 7 H. 2 (d) After the second iteration of the while loop, some of the variables have altered values. Enter the values of the following variables after the second while loop iteration: L = R= m= (e) After the third iteration of the while loop, some of the variables have altered values. Enter the values of the following variables after the third while loop iteration: L= R= m= (f) After the 3rd iteration of the while loop, the while loop terminates and the function returns a value. Enter the return value in this case: return value =

Elements Of Modern Algebra
8th Edition
ISBN:9781285463230
Author:Gilbert, Linda, Jimmie
Publisher:Gilbert, Linda, Jimmie
Chapter8: Polynomials
Section8.2: Divisibility And Greatest Common Divisor
Problem 31E
Question
This exercise refers to the binary search algorithm given below.
def Binary Search (a, t) :
L=0
R = len(a) - 1
while L <= R:
m = floor((L+R)/2)
if a[m] <t:
L = m +1
elif a[m] >t:
R=m-1
else:
return m
return -1
Suppose our list of increasing integers is shown in the table below
23467101215
Suppose we conduct the binary search algorithm on this list where we search for 12.
(a) In the language of the algorithm above, enter the correct values for the following variables for this particular search (where n is the length of the list):
n=
||a[1] =
||a[3] =
(b) After the first iteration of the while loop, what are the values of the following variables?
L=
R=
im =
".
(c) Intuitively, after the first iteration of the while loop, we have cut down our search to a set S of roughly half of the original numbers on the list. Check the numbers that are in the set S after the first iteration of the while loop:
S has the following elements:
□ A. 6
B. 4
C. 10
Transcribed Image Text:This exercise refers to the binary search algorithm given below. def Binary Search (a, t) : L=0 R = len(a) - 1 while L <= R: m = floor((L+R)/2) if a[m] <t: L = m +1 elif a[m] >t: R=m-1 else: return m return -1 Suppose our list of increasing integers is shown in the table below 23467101215 Suppose we conduct the binary search algorithm on this list where we search for 12. (a) In the language of the algorithm above, enter the correct values for the following variables for this particular search (where n is the length of the list): n= ||a[1] = ||a[3] = (b) After the first iteration of the while loop, what are the values of the following variables? L= R= im = ". (c) Intuitively, after the first iteration of the while loop, we have cut down our search to a set S of roughly half of the original numbers on the list. Check the numbers that are in the set S after the first iteration of the while loop: S has the following elements: □ A. 6 B. 4 C. 10
Suppose we conduct the binary search algorithm on this list where we search for 12.
(a) In the language of the algorithm above, enter the correct values for the following variables for this particular search (where n is the length of the list):
t =
n =
||a[1] =
||a[3] =
(b) After the first iteration of the while loop, what are the values of the following variables?
L =
R=
m=
(c) Intuitively, after the first iteration of the while loop, we have cut down our search to a set S of roughly half of the original numbers on the list. Check the numbers that are in the set S after the first iteration of the while loop:
S has the following elements:
□ A. 6
B. 4
C. 10
D. 3
E. 15
E 12
G. 7
H. 2
(d) After the second iteration of the while loop, some of the variables have altered values. Enter the values of the following variables after the second while loop iteration:
L =
R=
m=
(e) After the third iteration of the while loop, some of the variables have altered values. Enter the values of the following variables after the third while loop iteration:
L=
R=
m=
(f) After the 3rd iteration of the while loop, the while loop terminates and the function returns a value. Enter the return value in this case:
return value =
Transcribed Image Text:Suppose we conduct the binary search algorithm on this list where we search for 12. (a) In the language of the algorithm above, enter the correct values for the following variables for this particular search (where n is the length of the list): t = n = ||a[1] = ||a[3] = (b) After the first iteration of the while loop, what are the values of the following variables? L = R= m= (c) Intuitively, after the first iteration of the while loop, we have cut down our search to a set S of roughly half of the original numbers on the list. Check the numbers that are in the set S after the first iteration of the while loop: S has the following elements: □ A. 6 B. 4 C. 10 D. 3 E. 15 E 12 G. 7 H. 2 (d) After the second iteration of the while loop, some of the variables have altered values. Enter the values of the following variables after the second while loop iteration: L = R= m= (e) After the third iteration of the while loop, some of the variables have altered values. Enter the values of the following variables after the third while loop iteration: L= R= m= (f) After the 3rd iteration of the while loop, the while loop terminates and the function returns a value. Enter the return value in this case: return value =
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Elements Of Modern Algebra
Elements Of Modern Algebra
Algebra
ISBN:
9781285463230
Author:
Gilbert, Linda, Jimmie
Publisher:
Cengage Learning,
Algebra & Trigonometry with Analytic Geometry
Algebra & Trigonometry with Analytic Geometry
Algebra
ISBN:
9781133382119
Author:
Swokowski
Publisher:
Cengage
Linear Algebra: A Modern Introduction
Linear Algebra: A Modern Introduction
Algebra
ISBN:
9781285463247
Author:
David Poole
Publisher:
Cengage Learning