Questions: Feedback PARTICIPATION ACTIVITY 4.11.2: Using binary search to search a contact list. A contact list is searched for Bob. Assume the following contact list: Amy, Bob, Chris, Holly, Ray; Sarah, Zoe 1) What is the first contact searched? Check Show answer 2) What is the second contact searched? Check Show answer Feedback?

Feedback
PARTICIPATION
ACTIVITY
4.11.2: Using binary search to search a contact list.

A contact list is searched for Bob.
Assume the following contact list: Amy, Bob, Chris, Holly, Ray; Sarah, Zoe
1) What is the first contact searched?
Check

Show answer
2) What is the second contact searched?

Check
Show answer
Feedback?
Transcript text: Feedback PARTICIPATION ACTIVITY 4.11.2: Using binary search to search a contact list. A contact list is searched for Bob. Assume the following contact list: Amy, Bob, Chris, Holly, Ray; Sarah, Zoe 1) What is the first contact searched? Check Show answer 2) What is the second contact searched? $\square$ Check Show answer Feedback? Binary search algorithm
failed

Solution

failed
failed

To answer the questions about using binary search to search for "Bob" in the given contact list, we need to understand how the binary search algorithm works. Binary search works by repeatedly dividing the search interval in half. If the value of the search key is less than the item in the middle of the interval, the algorithm narrows the interval to the lower half. Otherwise, it narrows it to the upper half. This process continues until the value is found or the interval is empty.

Given contact list: Amy, Bob, Chris, Holly, Ray, Sarah, Zoe

  1. What is the first contact searched? The answer is Chris. Explanation: In binary search, we start by checking the middle element of the list. The middle element of the list [Amy, Bob, Chris, Holly, Ray, Sarah, Zoe] is Chris (the 3rd element in a 7-element list).

  2. What is the second contact searched? The answer is Bob. Explanation: Since "Bob" is less than "Chris" (alphabetically), the search will continue in the lower half of the list [Amy, Bob]. The middle element of this sublist is Bob.

So, the first contact searched is Chris, and the second contact searched is Bob.

Was this solution helpful?
failed
Unhelpful
failed
Helpful