Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Import modules and declare variables and also Print instructions Read in phone b

ID: 3534749 • Letter: I

Question

  1. Import modules and declare variables and also Print instructions
  2. Read in phone book file
  3. Create file
  4. Create scanner for file
  5. Determine number of entries
  6. Read each entry:
    1. Put names in a name array
    2. Put phone numbers in a number array
  7. Figure out if user wants to search via name or number
  8. Sort both arrays using the appropriate method (both are provided for you)
  9. sortByNames if user wants to search using a name
  10. sortByNumbers if user wants to search using a number
  11. Perform a binary search on the appropriate array
  12. Pick low bound to zero high bound to size of the array
  13. look until query is found or nowhere else to look
    1. set the current position to half way between low and high
    2. store the current position and stop if we have the right answer
    3. check if we are too low or too high
    4. adjust the appropriate bound to shrink the search area
  14. If we found our search query: print the corresponding name and number at that position
  15. If not: inform the user their search did not yield any results
  16. Ask the user if they would like to search again or quit

Explanation / Answer

I can do this contact me on timacs12@gmail.com. you can rate me after getting the answer