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
Create five circles like the Olympic Rings. fill them with the colors given below
Eva8 [605]

Answer: testing

Explanation:

Testing an answer with multiple attachments

3 0
3 years ago
Bunco is a dice throwing game that requires no decisions to be made or skill on the part of the player just luck. In the simples
anygoal [31]
Abcdefghijklmnopqrstuvwxyz now I know my abcs, next time won’t you sing with me :)
8 0
2 years ago
When coding, how do you get animations to work??
Nina [5.8K]

Answer:

Blender's animation & rigging if you are talking about 3d modeling.

Explanation:

Blender is a standard free to use universally used software used in animation for most standard games. You learn to model, then to rig with bones, then to animate. Animations don't entirely go with coding unless you are calling them in the code to make them play.

7 0
4 years ago
What does every shot have with regards to depth?
djyliett [7]

This can be used to capture a larger area of acceptably sharp images. This can also be referred to as a deep depth of field, and some cinematographers will simply use the term “depth” to describe shots with a large DOF. It can also be referred to as deep focus.
5 0
3 years ago
Which of the following is true of functions?
SVETLANKA909090 [29]

Answer:

only D.

Explanation:

A is false because you can only declare it once, then call it multiple times.

B is false does not affect the number of commands. You can expect that the function commands are run multiple times.

C is false because the amount of work the program has to do does not change.

D is spot on.

3 0
3 years ago
Other questions:
  • Hannah had been a newspaper carrier for four years. Each year she delivered more papers then the year before. The first year she
    13·1 answer
  • I NEED HELP!!!
    9·2 answers
  • When there is a limited amount of a product, such as rare art or collectible
    13·1 answer
  • Your electric service has been failing with some frequency lately because of a lot of storms, and you are looking for more peace
    14·1 answer
  • This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by
    11·1 answer
  • a machine needs a minimum of 100 sec to sort 1000 names by quicksort what is the approximate worst case time needed to sort 100
    13·1 answer
  • How would our lives be different without computers at home?
    6·1 answer
  • The red dot says ‘you tried to read records from a table called “Netflix Content” but that table doesn’t exist in this’
    7·1 answer
  • How to get the whole number of a fraction in python
    6·1 answer
  • If you want to create a line of code that will not appear in the interpreter, what symbol should begin the line?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!