a. Derive f(n), a function giving the number of comparisons performed by the BSA in terms of the size of the list n. For simplicity, assume n equals an integer power of 2; that is, n = 2k, k E N, the natural numbers (positive integers).
a. Derive f(n), a function giving the number of comparisons performed by the BSA in terms of the size of the list n. For simplicity, assume n equals an integer power of 2; that is, n = 2k, k E N, the natural numbers (positive integers).
Related questions
Question
![The Binary Search Algorithm (BSA) is described by this pseudocode:
ALGORITHM 3 The Binary Search Algorithm.
procedure binary search (x: integer, a₁, a2, ..., an: increasing integers)
i = 1 {i is left endpoint of search interval}
j:= n {j is right endpoint of search interval}
while i < j
m := [(i+j)/2]
if x > am then i:=m+1
else j := m
if x = a; then location := i
else location : 0
return location{location is the subscript i of the term a; equal to x, or 0 if x is not found}
a. Derive f(n), a function giving the number of comparisons performed by the BSA in
terms of the size of the list n. For simplicity, assume n equals an integer power of 2;
that is, n = 2k, k E N, the natural numbers (positive integers).](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ffa06b614-497d-40f0-b077-f4b4fca47baf%2F9d4dc3ed-836e-4bc6-b9c4-0511abd24a0f%2F5i8r6du_processed.png&w=3840&q=75)
Transcribed Image Text:The Binary Search Algorithm (BSA) is described by this pseudocode:
ALGORITHM 3 The Binary Search Algorithm.
procedure binary search (x: integer, a₁, a2, ..., an: increasing integers)
i = 1 {i is left endpoint of search interval}
j:= n {j is right endpoint of search interval}
while i < j
m := [(i+j)/2]
if x > am then i:=m+1
else j := m
if x = a; then location := i
else location : 0
return location{location is the subscript i of the term a; equal to x, or 0 if x is not found}
a. Derive f(n), a function giving the number of comparisons performed by the BSA in
terms of the size of the list n. For simplicity, assume n equals an integer power of 2;
that is, n = 2k, k E N, the natural numbers (positive integers).
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 8 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)