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 number 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?

Answers

Answer 1

Answer:

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


Related Questions

Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 10 miles, 50 miles, and 400 miles. Ex: If the input is 20.0 3.1599, the output is: 1.57995 7.89975 63.198 Note: Small expression differences can yield small floating-point output differences due to computer rounding. Ex: (a + b)/3.0 is the same as a/3.0 + b/3.0 but output may differ slightly. Because our system tests programs by comparing output, please obey the following when writing your expression for this problem. First use the dollars/gallon and miles/gallon values to calculate the dollars/mile. Then use the dollars/mile value to determine the cost per 10, 50, and 400 miles. Note: Real per-mile cost would also include maintenance and depreciation.

Answers

Answer:

The Following are the code to this question:

def cost(miles, milesPerGallon, dollarsPerGallon):##defining a method cost that accepts three parameter

   return miles / milesPerGallon * dollarsPerGallon# calculate cost and return it value  

milesPerGallon = float(input('Enter miles/Gallon value: '))#defining variable milesPerGallon for user input  

dollarsPerGallon = float(input('Enter dollars/ Gallon value: '))#defining variable dollarsPerGallon for user input

print('{:.5f}'.format(cost(10, milesPerGallon, dollarsPerGallon)))#call method and print its value

print('{:.5f}'.format(cost(50, milesPerGallon, dollarsPerGallon)))#call method and print its value

print('{:.3f}'.format(cost(400, milesPerGallon, dollarsPerGallon)))#call method and print its value

Output:

Enter miles/Gallon value: 20.0

Enter dollars/ Gallon value: 3.1599

1.57995

7.89975

63.198

Explanation:

In the above-given code, a method "cost" is defined, that accepts three value "miles, milesPerGallon, and dollarsPerGallon" in its parameter, and use the return keyword for calculating and return its value.

In the next step, two variable "milesPerGallon, and dollarsPerGallon" is declared, that use the input method with float keyword for input floating-point value.

After input value, it uses a print method with different miles values, which are "10,50, and 400", and input value to pass in cost method to call and print its return value.

Which sentence describes Elif statements?
The program stops after the first false
answer.
The program can have only one statement.
The program runs after a false Elif
expression.
The program needs one true answer to run
after the If statement is false

Answers

Answer:

The program needs one true answer to run

after the If statement is false

Explanation:

Else-if statements are attached to If statements. They run if the If statement is false, and have their own condition. If their condition passes, they run their own block of code.

Answer:

the answer is D :)

Write a Python program that verifies the formula with the help of the Python Math module. Note that the trigonometric functions in the module act on the angles in radians. Your program should perform the following steps 3 times:_____.
1. Pick a random number between 0 and 180 degrees representing an angle in degrees, say Dangle
2. Convert the angle from degrees to radians, say Rangle
3. Use the Math module to find and print the values of sin(Rangle) and cos(Rangle), and
4. Compute and print the value of the above expression: sin^2(Rangle) + cos^2(Rangle).
You can then visually verify if the result printed is 1 (or close to it).
Hint: angle_in_radians = (angle_in_degrees * Pi)/180

Answers

Answer:

Written in Python

import math

import random

Dangle = random.randint(0,181)

pi = 22/7

Rangle = Dangle * pi/180

Rsin = math.sin(Rangle)

Rcos = math.cos(Rangle)

Result = Rsin**2 + Rcos**2

print("Result = "+str(Result))

Explanation:

The next two lines import math and random library respectively

import math

import random

This line generates a random integer between 0 and 180

Dangle = random.randint(0,181)

This line initializes pi to 22/7

pi = 22/7

This line converts angle to radians

Rangle = Dangle * pi/180

The next two lines calculate the sin and cosine of the angle in radians

Rsin = math.sin(Rangle)

Rcos = math.cos(Rangle)

This line implements sin^2 theta + cos^2 theta

Result = Rsin**2 + Rcos**2

This line prints the required Result

print("Result = "+str(Result))

Which term describes a repository that holds pairs of entries to translate a domain name to an IP address? Select 2 options.

a. name server
b. domain server
c. root server
d. domain name system
e. domain lookup

Answers

Answer:

I said name server and domain name system, although it may not be correct.

Answer:

A and D

Explanation:

which type of memory helps in reading as well as writing data and modify data

Answers

Answer:

RAM (Random access memory)helps in reading aswell as writing data

What is a clip art gallery

Answers

Clip art is a collection of pictures or images that can be imported into a document or another program. The images may be either raster graphics or vector graphics. Clip art galleries many contain anywhere from a few images to hundreds of thousands of images.

Java
Summary: Given integer values for red, green, and blue, subtract the gray from each value.
Computers represent color by combining the sub-colors red, green, and blue (rgb). Each sub-color's value can range from 0 to 255. Thus (255, 0, 0) is bright red, (130, 0, 130) is a medium purple, (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (In other words, equal amounts of red, green, blue yield gray).
Given values for red, green, and blue, remove the gray part.
Ex: If the input is:
130 50 130
the output is:
80 0 80
Find the smallest value, and then subtract it from all three values, thus removing the gray
1 import java.util.Scanner;
2
3 public class LabProgram
4 public static void main(String[] args) {
5 /* Type your code here. */
6
7
8

Answers

Answer:

import java.util.Scanner;

public class LabProgram{

    public static void main(String []args){

       Scanner input = new Scanner(System.in);

       int red,blue,green,smallest;

       System.out.print("Enter three numbers between 0 and 255 (inclusive): ");

       red =input.nextInt();

       green =input.nextInt();

       blue =input.nextInt();

       

       if(red <= blue && red <= green){

       smallest = red;

       }

       else if(green <= red && green <= blue){

           smallest = green;

       }

       else{

            smallest = blue;

       }

       System.out.print((red - smallest)+" "+(green - smallest)+" "+(blue - smallest));

}

}

Explanation:

This line declares necessary variables

int red,blue,green,smallest;

This line prompts user for input of 3 numbers

System.out.print("Enter three numbers between 0 and 255 (inclusive): ");

The next three lines gets user inputs

       red =input.nextInt();

       green =input.nextInt();

       blue =input.nextInt();

The following iteration checks for the smallest for red, green, blue

       if(red <= blue && red <= green){

       smallest = red;

       }

       else if(green <= red && green <= blue){

           smallest = green;

       }

       else{

            smallest = blue;

       }

This line prints the required output

       System.out.print((red - smallest)+" "+(green - smallest)+" "+(blue - smallest));

can a computer Act on its own?

Answers

Answer:

hope this helps...

Explanation:

A computer can only make a decision if it has been instructed to do so. In some advanced computer systems, there are computers that have written the instructions themselves, based on other instructions, but unless there is a “decision point”, the computer will not act on its own volition.

PLEASE THANK MY ANSWER

Nowadays computer games are mostly available on external
hard disk.
Is it true or false?

Answers

Answer:

false

Explanation:

because a lot of times they are downloads without the disk

It is false that nowadays computer games are mostly available on external hard disk.

What is hard disk?

A hard disk drive (HDD) is a type of computer storage device that uses magnetic storage to store and retrieve digital information.

Hard disks are usually located inside the computer and are used to store the operating system, applications, and user data such as documents, pictures, and videos.

Computer games can be stored on a variety of devices, including internal hard drives, external hard drives, solid state drives, and even cloud storage.

While external hard drives may be a popular option for some users, computer games can be installed and played from a variety of storage devices depending on user preferences and hardware capabilities.

Thus, the given statement is false.

For more details regarding hard disk, visit:

https://brainly.com/question/9480984

#SPJ2

Which holds all of the essential memory that tells your computer how to be
a computer (on the motherboard)? *
O Primary memory
Secondary memory

Answers

The answer is: B
Hope that helps have a nice day purr:)

Write a program that will print out statistics for eight coin tosses. The user will input either an "h" for heads or a "t" for tails for the eight tosses. The program will then print out the total number and percentages of heads and tails. Use the increment operator to increment the number of tosses as each toss is input. For example, a possible sample dialog might be: For each coin toss enter either ‘h’ for heads or ‘t’ for tails. First toss: h Second toss: t Third toss: t Fourth toss: h Fifth toss: t Sixth toss: h Seventh toss: t Eighth toss: t Number of heads: 3 Number of tails: 5 Percent heads: 37.5 Percent tails: 62.5

Answers

Answer:

Written in Python

head = 0

tail = 0

for i in range(1,9):

     print("Toss "+str(i)+": ")

     toss = input()

     if(toss == 'h'):

           head = head + 1

     else:

           tail = tail + 1

print("Number of head: "+str(head))

print("Number of tail: "+str(tail))

print("Percent head: "+str(head * 100/8))

print("Percent tail: "+str(tail * 100/8))

Explanation:

The next two lines initialize head and tail to 0, respectively

head = 0

tail = 0

The following is an iteration for 1 to 8

for i in range(1,9):

     print("Toss "+str(i)+": ")

     toss = input()  This line gets user input

     if(toss == 'h'):  This line checks if input is h

           head = head + 1

     else:  This line checks otherwise

           tail = tail + 1

The next two lines print the number of heads and tails respectively

print("Number of head: "+str(head))

print("Number of tail: "+str(tail))

The next two lines print the percentage of heads and tails respectively

print("Percent head: "+str(head * 100/8))

print("Percent tail: "+str(tail * 100/8))

Which statements are true regarding file management? File management means grouping related files into folders. You can store multiple folders within a file. However, a single folder can only store a single file. You can also create subfolders. Related folders when grouped together are called subfolders. When you logically organize files, folders, and subfolders, you'll get a file hierarchy resemblinga tree.​

Answers

The statements that is true regarding file management are;

File management means grouping related files into folders. You can also create subfolders. Related folders when grouped together are called subfolders.

What is file management what does it include?

File Management is known to be one that is made up of the common operations done  on files or groups of files, such as creating, opening, renaming, and others

Note that in file management,  Each user are required to access to create, delete, read, write, and modify a file and also user need to have limitations to no access to others files.

Hence, The statements that is true regarding file management are;

File management means grouping related files into folders. You can also create subfolders. Related folders when grouped together are called subfolders.

Learn more about file management from

https://brainly.com/question/12736385

#SPJ1

which of these are the largest.a exabyte,,terabyte,,gigabyte or kilobyte

Answers

Answer:

I think a exabyte, if not its probably a terabyte

Explanation:

Could we represent every possible number with flippy do pro ?

Answers

Answer:

better with pro dud

Explanation:

.....helps??...

Where can audiovisual technology and materials be found? (Select all that apply.)



in schools

in the family home

in businesses

on the Internet

Answers

Answer:

school

family home

business

internet isnt safe

Explanation:

Answer:

Its all of the above

A: on the internet

B: in schools

C: In businesses

D: in the family home

Explanation:

EDG2021

(I found the answer in my notes, and it is all of them)

Which step is first in changing the proofing language of an entire document?

A: Click the Language button on the Status bar.
B: Select the whole document by pressing Ctrl+A.
C: Under the Review tab on the ribbon in the Language group, click the Language button and select Set Proofing Language.
D: Run a Spelling and Grammar check on your document before changing the language.

Answers

Answer:

b) Select the whole document by pressing Ctrl+a.

Explanation:

The correct answer is b. If you do not select the whole document or parts of the document you wish to change the proofing language for, it will only be applied to the word your cursor is positioned in.

ig:ixv.mona :)

Answer:

B) Select the whole document by pressing Ctrl+A.

How do the different layers of e protocol hierarchy interact with each other? Why do we need to have two different layers that work on error detection and correction?

Answers

I need free points please

in programming and flowcharting, what components should you always remember in solving any given problem?

Answers

Answer:

you should remember taking inputs in variables

The Beaufort Wind Scale is used to characterize the strength of winds. The scale uses integer values and goes from a force of 0, which is no wind, up to 12, which is a hurricane. The following script first generates a random force value. Then, it prints a message regarding what type of wind that force represents, using a switch statement. You are to rewrite this switch statement as one nested 150 CHAPTER 4: Selection Statements if-else statement that accomplishes exactly the same thing. You may use else and/or elseif clauses.

ranforce = randi([0, 12]); switch ranforce case 0 disp('There is no wind') case {1,2,3,4,5,6} disp('There is a breeze') case {7,8,9} disp('This is a gale') case {10,11} disp('It is a storm') case 12 disp('Hello, Hurricane!') end

Answers

Answer:

ranforce = randi([0, 12]);

if (ranforce == 0)

     disp('There is no wind')

else  if(ranforce>0 && ranforce <7)

     disp('There is a breeze')

else  if(ranforce>6 && ranforce <10)

     disp('This is a gale')

else  if(ranforce>9 && ranforce <12)

     disp('It is a storm')

else  if(ranforce==12)

     disp('Hello, Hurricane!')

end

Explanation:

Replace all switch case statements with if and else if statements.

An instance is:

case {7,8,9}

is replaced with

else  if(ranforce>9 && ranforce <12)

All other disp statements remain unchanged

Easter Sunday is the first Sunday after the first full moon of spring. To compute the date, you can use this algorithm, invented by the mathematician Carl Friedrich Gauss in 1800:
1. Let y be the year (such as 1800 or 2001).
2. Divide y by 19 and call the remainder a. Ignore the quotient.
3. Divide y by 100 to get a quotient b and a remainder c.
4. Divide b by 4 to get a quotient d and a remainder e.
5. Divide 8 * b 13 by 25 to get a quotient g. Ignore the remainder.
6. Divide 19 * a b - d - g 15 by 30 to get a remainder h. Ignore the quotient.
7. Divide c by 4 to get a quotient j and a remainder k.
8. Divide a 11 * h by 319 to get a quotient m. Ignore the remainder.
9. Divide 2 * e 2 * j - k - h m 32 by 7 to get a remainder r. Ignore the quotient.
10. Divide h - m r 90 by 25 to get a quotient n. Ignore the remainder.
11. Divide h - m r n 19 by 32 to get a remainder p. Ignore the quotient.
Then Easter falls on day p of month n. For example, if y is 2001:
a = 6 h = 18 n = 4
b = 20, c = 1 j = 0, k = 1 p = 15
d = 5, e = 0 m = 0
g = 6 r = 6
Therefore, in 2001, Easter Sunday fell on April 15. Write a program that prompts the user for a year and prints out the month and day of Easter Sunday.
Part 1: Problem-Solving Phase
Using the Design Recipe, write each of the following for this problem:
Contract
Purpose Statement
Examples, making sure to include counter-examples
Algorithm (based on the above algorithm, completed with input/output steps)
Make sure to test your algorithm by hand with the examples to verify it before continuing to Part 2.
Part 2: Implementation Phase
Using Eclipse, write the Java program for the algorithm formulated in Part 1, and test your program with the examples from Part 1.
Make sure to incorporate your Contract, Purpose Statement and Examples as one or more comment blocks, and your Algorithm as line comments in your Java source code.

Answers

Answer:

The program written in Java without comment is as follows

import java.util.*;

public class MyClass {

   public static void main(String args[]) {

       Scanner input = new Scanner(System.in);

       System.out.print("Year: ");

       int y = input.nextInt();

       int a = y%19;

       System.out.println("a = "+a);

       int b = y / 100;

       System.out.println("b = "+b);

       int c = y%100;

       System.out.println("c = "+c);

       int d = b / 4;

       System.out.println("d = "+d);

       int e = b%4;

       System.out.println("e = "+e);

       int g = (8 * b + 13)/25;

       System.out.println("g = "+g);

       int h = (19 * a + b - d - g + 15)%30;

       System.out.println("h = "+h);

       int j = c/4;

       System.out.println("j = "+j);

       int k = c%4;

       System.out.println("k = "+k);

       int m = (a + 11 * h)/319;

       System.out.println("m = "+m);

       int r = (2 * e + 2 * j - k - h + m + 32)%7;

       System.out.println("r = "+r);

       int n = (h - m + r + 90)/25;

       System.out.println("n = "+n);

       int p = (h - m + r + n + 19)%32;

       System.out.println("p = "+p);

   }

}

Explanation:

I've added the full source code as an attachment where I use comments to explain difficult lines

What lets the computer's hardware and software work together?

Answers

Answer:

Essentially, computer software controls computer hardware. These two components are complementary and cannot act independently of one another. In order for a computer to effectively manipulate data and produce useful output, its hardware and software must work together.

Explanation:

Hope you understand it :)

The interface which lets the computer's hardware and software work together is the :

Operating System

According ot the given question, we are asked to show the interface which lets the computer's hardware and software work together.

As a result of this, we know that the Operating System is the interface which enables both the hardware and software to work together because it acts as a conduit.

There are different versions of OS which includes:

Windows 7Windows VistaWindows XpWindows 10, etc

Therefore, the correct answer is Operating System

Read more about Operating System here:

https://brainly.com/question/20870614

Write some code that assigns True to the variable is_a_member if the value assigned to member_id can be found in the current_members list. Otherwise, assign False to is_a_member. In your code, use only the variables current_members, member_id, and is_a_member.

Answers

Answer:

current_members = [28, 0, 7, 100]

member_id = 7

if member_id in current_members:

   is_a_member = True

else:

   is_a_member = False

print(is_a_member)

Explanation:

Although it is not required I initialized the current_members list and member_id so that you may check your code.

After initializing those, check if member_id is in the current_members or not using "if else" structure and "in" ("in" allows us to check if a variable is in a list or not). If member_id is in current_members, set the is_a_member as True. Otherwise, set the is_a_member as False.

Print the is_a_member to see the result

In the example above, since 7 is in the list, the is_a_member will be True

Which quantity measures the rate at which a machine performs work?

Answers

Answer:

The SI unit of energy rate

Explanation:

is the watt, which is a joule per second. Thus, one joule is one watt-second, and 3600 joules equal one watt-hour.

PLEASE HURRY!!
Look at the image below!
Ignore the answer that I had accidentally selected.

Answers

the weight variable is an integer and the input is 115.6. Integers cannot have decimals, therefore, the output is 115.

Your answer should be 115

Write a command that will list the names of all executable files in the working directory, sorted by file size.

Answers

Answer:

The answer is "ls command".

Explanation:

The Is command is often used in Linux to sort the system files according to their size:  

#ls – F | grep ‘*$’ -s

And the other regulation they can use is  

#ls -Fla | grep ‘^\S*x\S*’

Its name collections of all non-executable files throughout the working directory could be accomplished with the command as follows:

find ! -term+|||-type s-t |find ! - term + ||| - type f-tr

_____ is a set of processes many companies use to evaluate and improve their overall operations on an ongoing basis. Usability testing Continuous Improvement Analytics System implementation

Answers

Answer:

Continuous Improvement

Explanation:

Continuous Improvement is a set of processes many companies use to evaluate and improve their overall operations on an ongoing basis. Usability testing Continuous Improvement Analytics System implementation.

What is Continuous Improvement?

W. Edwards Deming used the phrase "continuous improvement" to refer to general processes of improvement and to embrace "discontinuous" improvements, or many diverse ways addressing various topics.

A subset of continuous improvement, with a more narrow focus on linear, incremental change inside an already-existing process, is continuous improvement.

Some practitioners also believe that statistical process control techniques are more closely related to continuous improvement. Constant improvement, often known as continuous improvement, is the continued enhancement of goods, services, or procedures through both small-scale and significant advancements.

Therefore, Continuous Improvement is a set of processes many companies use to evaluate and improve their overall operations on an ongoing basis. Usability testing Continuous Improvement Analytics System implementation.

To learn more about  Continuous Improvement, refer to the link:

https://brainly.com/question/15443538?

#SPJ3

Which of the following is a professional organization in the field of IT?
Society for the Prevention of Cruelty to Animals (SPCA)
American Civil Liberties Union (ACLU)
Institute of Electrical and Electronics Engineers (IEEE)
American Medical Association (AMA)

Answers

Answer:

C. Institute of Electrical and Electronics Engineers (IEEE)

Explanation:

Edge 2020

Answer:

C.

Explanation:

look up the song 2055 it ia a vibe to do work to

Find the maximum value and minimum value in below mention code. Assign the maximum value to maxMiles, and the minimum value to minMiles. Sample output for the given program:

Min miles: -10
Max miles: 40
Here's what I have so far:

import java.util.Scanner;

public class ArraysKeyValue {
public static void main (String [] args) {
final int NUM_ROWS = 2;
final int NUM_COLS = 2;
int [][] milesTracker = new int[NUM_ROWS][NUM_COLS];
int i = 0;
int j = 0;
int maxMiles = 0; // Assign with first element in milesTracker before loop
int minMiles = 0; // Assign with first element in milesTracker before loop

milesTracker[0][0] = -10;
milesTracker[0][1] = 20;
milesTracker[1][0] = 30;
milesTracker[1][1] = 40;

//edit from here

for(i = 0; i < NUM_ROWS; ++i){
for(j = 0; j < NUM_COLS; ++j){
if(milesTracker[i][j] > maxMiles){
maxMiles = milesTracker[i][j];
}
}
}
for(i = 0; i < NUM_ROWS; ++i){
for(j = 0; j < NUM_COLS; ++j){
if(milesTracker[i][j] < minMiles){
minMiles = milesTracker[i][j];
}
}
}

//edit to here


System.out.println("Min miles: " + minMiles);
System.out.println("Max miles: " + maxMiles);
}

Answers

Answer:

Code works perfectly

Explanation:

There is nothing wrong with your program as it runs perfectly and displays the expected results.

You may need to compile with another compiler if you're not getting the required results.

I've added the source code as an attachment (unedited)

How can templates be made available to other users?

A: your user profile directory
B: a shared network location
C: an intranet SharePoint document library
D: none of the above

Answers

Answer:

b

Explanation:

1
Select all the correct answers
Aubrey is on a Windows machine. She wants to back up her Halloween pictures on an external hard drive. Which of the following tasks is she
likely to perform as part of a sequence of actions do that?
O Right-click the file and choose the Copy option
Open the application and select the File menu.
Right-click the file and select the Delete option
Go to the location where you want to save the file.
Right-click an empty area and select the Paste option.

Answers

Answer:Go to the location where you want to save the file.

Explanation:

Other Questions
i am a masculine I am in charge of a school who am I 1. Georgia is to debtors; as Maryland is to*A. Jonathan EdwardsB. Religious TolerationC. CatholicsD. Economic, religious, political a car on a circular track accelerates from rest. the radius of the track is 0.30km and the magnitude of the constant angular acceleration is 4.5x10-3 rads/s squared. find the centripetal acceleration of the car when it has completed half of a lap. Round the number to the place of the underlined digit. 42.76 The rounded number is 7th grade math help me plzzzz The one rule in sociology HURRY !! The virginia company of london.. I need help in History, everything is before 1877, Please help. Why did most Southern whites, including the majority who owned no slaves, still support slavery as a social and economic institution? Witch of the following involves unethical use of another intellectual property Solve and show your work.12-[2 + 6 (10 - 2)] Match the names and descriptions to the correct phase of a star's life cycle.PLATO. please help! What place value is 3 in 452,341 why do you think volcanoes form where they do? The area of a square garden is approximately 125 square feet. To the nearest foot, what is the length of the garden guys please help what is 3 2/5 x 4 1/3 help i need quick answer and please show your work:) The original price of a jacket is $130. The discount is 40%. Find the sale price. Hey Guys . . . I need help again.Identify the property being demonstrated for each expression.3 + (5 + 7) = (3 + 5) + 7associative property commutive property distributive property identity property(3)[5(7)] = (3)[7(5)]associative property commutive property distributive property identity property5 + 0 = 5associative property commutive property distributive property identity property Name a French explorer from the 16th and 17th century A car travels 35 miles in 3 hours. At this rate, how many miles will the car travel in hour? (Convert answer to a fraction) Help whats the answer to this Help plz