In: Computer Science
Below is a small part of the phone list of B. Obama. The phone numbers and addresses have been left out here.
a) Show with binary search how you would look up the person Casy in this list (manually).
b) Explain that linear search, in this case, is faster than binary search.
Phone List (1) Allen (2) Baley (3) Boyer (4) Casy (5) Davis (6) Davison (7) Glen (8) Greer (9) Haley (10) Hanson (11) Harrison (12) Lister (13) Mendel (14) Morgenstern (15) Patton (16) Perkins (17) Quinn (18) Reed (19) Schmidt (20) Woolf
Phone List (1) Allen (2) Baley (3) Boyer (4) Casy (5) Davis (6) Davison (7) Glen (8) Greer (9) Haley (10) Hanson (11) Harrison (12) Lister (13) Mendel (14) Morgenstern (15) Patton (16) Perkins (17) Quinn (18) Reed (19) Schmidt (20) Woolf a) As there are 20 records in the list.. binary search is probed in below faishon: Haley(Index 10) -> Davis(Index 5) -> Baley(Index 2) -> Boyer(Index 3) -> Casy(Index 4) Total 5 probing. b) Linear search is probed in below faishon: Allen(Index 1) -> Baley(Index 2) -> Boyer(Index 3) -> Casy(Index 4) Total 4 probing. Hence linear search does less probing, so it is better in this particular case.
************************************************** Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.
Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.