1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Nikitich [7]
3 years ago
5

You have a large text file of people. Each person is represented by one line in the text file. The line starts with their ID num

ber and after that, has the person's name. The lines are sorted by ID number in ascending order. There are n lines in this file. You write a search function that returns the name of a person whose ID number is given The simplest way to do that would be to program a loop that goes through each line and compares the ID number in the line against the given ID number. If there is a match, then it returns the name in that line. This is very inefficient, because the worst-case scenario is that this program needs to go through almost everyone the person we are looking for could be last. using the fact that he tli s sored wil greany speed up the processbus to use a birarysearch alkrhm We go to the middle line of the file first and compare the ID found there (P) to the given ID (Q). (f the number of lines is even, we go above or below the arithmetic middle.) if P=Q then our algorithm terminates . we have found the person we are looking for. If P is less than Q, that means that the person we are looking for is in the second half of the file. We now repeat our algorithm on the second half of the file. If P is greater than Q, that means that the person we are looking for is in the first half of the file. We now repeat our algorithm on the first half of the file.
Required:
Of what order is the worst-case number of comparison operations that needed for this algorithm to terminate?
Computers and Technology
1 answer:
seropon [69]3 years ago
7 0

Answer:

...............fp......

You might be interested in
11. How much time will you save on a
matrenka [14]

Answer:

Less than 1 min, so A.

Explanation:

Hope this helps!

( it really does help you save)

7 0
3 years ago
When trying to solve a problem, Bret uses a logical, step-by-step formula called ________.
Alexxx [7]

Answer:

B) An Algorithm

Explanation:

An algorithm is defined as the step-by-step solution to a given problem that follows a logical sequence and which is also finite. In mathematics and computer science, the first step in solving a given problem is writing out the algorithm which will include steps for calculations, decisions, data processing, input/output etc. There are scientific ways of representing algorithms through the use of flowcharts, pseudocodes, data flow diagrams etc.

5 0
3 years ago
Which of the following<br> Services are<br> functions performed<br> by the general office?
GaryK [48]

Answer:

comment the choices please

6 0
2 years ago
It skills which move well between industries are considered?
Butoxors [25]

Answer:

They are termed as ethics. But remember different industries have a different set of ethics or rules that they expect their employees to follow. However, some that go well with all are common to all. And they are the standard ethics that are followed by all the industries. Failing to these is never expected.

Explanation:

Please check the answer section.

6 0
3 years ago
What tag pair is used to link web page documents to each other?
V125BC [204]
<span><BODY> …</BODY>
It identifies the document's body area, which contains the Web page contents that appear in the browser window.
Hope this is the answer you are looking for.</span>
8 0
4 years ago
Other questions:
  • Create a variable ‘temp’ and assign the value in Celsius. Display the message ‘It’s extremely hot day today!’ if the temperature
    8·1 answer
  • Which tab provide text formatting features
    11·1 answer
  • For every $1 of deposits, the banks can increase ________________ by the value of the Money Multiplier.
    15·1 answer
  • Explain how class (static) variables and methods differ from their instance counterparts. Give an example of a class that contai
    7·1 answer
  • A spreadsheet has some values entered: Cell A1 contains 10, cell A2 contains 14, cell A3 contains 7. You enter in cell A4 the fo
    7·2 answers
  • Here we have a program which is calling the subtract function to calculate the difference between two numbers. The value from th
    7·1 answer
  • Which of these is an example of collective voice?
    8·2 answers
  • Which group contains the command to manually conduct a spell check ?
    9·1 answer
  • How many triangles can you make if the side lengths are 4 cm, 5 cm, and 11 cm?
    10·1 answer
  • In a typical day, what types of Computer-Mediated Communication do you use?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!