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 =

Advanced Engineering Mathematics
10th Edition
ISBN:9780470458365
Author:Erwin Kreyszig
Publisher:Erwin Kreyszig
Chapter2: Second-order Linear Odes
Section: Chapter Questions
Problem 1RQ
icon
Related questions
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
Similar questions
Recommended textbooks for you
Advanced Engineering Mathematics
Advanced Engineering Mathematics
Advanced Math
ISBN:
9780470458365
Author:
Erwin Kreyszig
Publisher:
Wiley, John & Sons, Incorporated
Numerical Methods for Engineers
Numerical Methods for Engineers
Advanced Math
ISBN:
9780073397924
Author:
Steven C. Chapra Dr., Raymond P. Canale
Publisher:
McGraw-Hill Education
Introductory Mathematics for Engineering Applicat…
Introductory Mathematics for Engineering Applicat…
Advanced Math
ISBN:
9781118141809
Author:
Nathan Klingbeil
Publisher:
WILEY
Mathematics For Machine Technology
Mathematics For Machine Technology
Advanced Math
ISBN:
9781337798310
Author:
Peterson, John.
Publisher:
Cengage Learning,
Basic Technical Mathematics
Basic Technical Mathematics
Advanced Math
ISBN:
9780134437705
Author:
Washington
Publisher:
PEARSON
Topology
Topology
Advanced Math
ISBN:
9780134689517
Author:
Munkres, James R.
Publisher:
Pearson,