47.1k views
4 votes
Finding a piece of data in a sorted list can be done in 30 questions (2^30 is 1,073,741,824). So how many questions would it take to find a piece of data in a list of 2 billion pieces of data?

a. 31
b. 32
c. 33
d. 34

User Nilaja
by
7.7k points

1 Answer

3 votes

Final answer:

To find a piece of data in a list of 2 billion using binary search, it would take 31 questions.

Step-by-step explanation:

Finding a piece of data in a sorted list using a binary search method means you can effectively halve the list with each question you ask. Given that 231 is 2,147,483,648, and 230 is 1,073,741,824, you can see that 231 is the first power of 2 greater than 2 billion. So, to find a piece of data in a list of 2 billion, it would take 31 questions.

User Ujjwal
by
8.2k points