Question

In: Computer Science

Below is a small part of the phone list of B. Obama. The phone numbers and...

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

Solutions

Expert Solution

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.


Related Solutions

Suppose you are given a file containing a list of names and phone numbers in the...
Suppose you are given a file containing a list of names and phone numbers in the form "First_Last_Phone." In C, Write a program to extract the phone numbers and store them in the output file. Example input/output: Enter the file name: input_names.txt Output file name: phone_input_names.txt 1) Name your program phone_numbers.c 2) The output file name should be the same name but an added phone_ at the beginning. Assume the input file name is no more than 100 characters. Assume...
Suppose you are given a file containing a list of names and phone numbers in the...
Suppose you are given a file containing a list of names and phone numbers in the form "First_Last_Phone." Write a program in C to extract the phone numbers and store them in the output file. Example input/output: Enter the file name: input_names.txt Output file name: phone_input_names.txt 1) Name your program phone_numbers.c 2) The output file name should be the same name but an added phone_ at the beginning. Assume the input file name is no more than 100 characters. Assume...
Suppose you are given a file containing a list of names and phone numbers in the...
Suppose you are given a file containing a list of names and phone numbers in the form "First_Last_Phone." Write a program to extract the phone numbers and store them in the output file. Example input/output: Enter the file name: input_names.txt Output file name: phone_input_names.txt 1) Name your program phone_numbers.c 2) The output file name should be the same name but an added phone_ at the beginning. Assume the input file name is no more than 100 characters. Assume the length...
Suppose you are given a file containing a list of names and phone numbers in the...
Suppose you are given a file containing a list of names and phone numbers in the form "First_Last_Phone." Write a program in C language to extract the phone numbers and store them in the output file. Example input/output: Enter the file name: input_names.txt Output file name: phone_input_names.txt 1) Name your program phone_numbers.c 2) The output file name should be the same name but an added phone_ at the beginning. Assume the input file name is no more than 100 characters....
Language C: Suppose you are given a file containing a list of names and phone numbers...
Language C: Suppose you are given a file containing a list of names and phone numbers in the form "First_Last_Phone." Write a program to extract the phone numbers and store them in the output file. Example input/output: Enter the file name: input_names.txt Output file name: phone_input_names.txt 1) Name your program phone_numbers.c 2) The output file name should be the same name but an added phone_ at the beginning. Assume the input file name is no more than 100 characters. Assume...
JavaScript (HTML) Task: Please read 10 numbers that are list below, sort the numbers and then...
JavaScript (HTML) Task: Please read 10 numbers that are list below, sort the numbers and then print those numbers. 10 numbers = { 9, 3, 2, 1, 10, 30, 4, 6, 7, 8} [Reference JavaScript code] <html> <body>     <H1>prompt()</h1>     <p id="pro"></p>     <script>        // Array creation        var num= new Array();               var ix = 0;        // Read 10 numbers        for (ix = 0; ix < 10; ix++)        {num[ix] = prompt("Enter a number");...
Write an application, Phone Numbers, that creates and prints a random phone number of the form...
Write an application, Phone Numbers, that creates and prints a random phone number of the form XXX-XXX-XXXX. Include the dashes in the output. The phone number has some constraints. Do not let the first three digits contain an 3 or 7 (but do not be more restrictive than that) and ensure that the second set of three digits is not greater than 825. Note that any of the digits can be zero and zeroes should be shown.
6. List below are the numbers of words spoken in a day by each member of...
6. List below are the numbers of words spoken in a day by each member of six different couples. Use a 0.05 significance level to test the claim that among couples, males speak more words in a day than females. Assume that the population differences is normally distributed. Male 5638 21,319 17,572 26,429 46,978 25,835 Female 5198 11,661 19,624 13,397 31,553 18,667 7. A sociologist wanted to estimate the difference in the amount of daily leisure time (in hours) of...
For segments (a) and (b), use the information below. The personal identification numbers (PINs) for ATMs...
For segments (a) and (b), use the information below. The personal identification numbers (PINs) for ATMs usually consist of four digits, chosen from 0, 1, 2, ….., 9. Suppose you notice that most of the PINs you hold have at least one “1,” which makes you wonder if the issuers of these numbers include many ones so that users will remember them more easily.                 Assume PIN numbers of 4 digits are assigned randomly. How many unique PIN numbers are...
The service department of a small city needs your help in solving the problem of assigning short phone numbers to its Fire,Sanitation, and Parks and Recreationdepartments.
Solve in C++The service department of a small city needs your help in solving the problem of assigning short phone numbers to its Fire,Sanitation, and Parks and Recreationdepartments.The phone numbers to be considered consist of three distinct digits, each ranging from 1 to 7. The sum of the selected three digits must be equal to 12. The Fire Department requires at least four phone numbers which must begin with the same digit, which in turn must be an even number.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT