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
monitta
3 years ago
14

uppose you are going on a road trip with friends. Unfortunately, your headlights are broken, so you can only drive in the daytim

e. Therefore, on any given day you can drive no more than d miles. You have a map with n different hotels and the distances from your start point to each hotel x 1 < x 2 < ... < x n . Your final destination is the last hotel. Describe an efficient greedy algorithm that determines which hotels you should stay in if you want to minimize the number of days it takes you to get to your destination. What is the running time of your algorithm
Computers and Technology
1 answer:
tiny-mole [99]3 years ago
6 0

Answer:

Explanation:

Algorithm:

a. In each day, you will have to loop through the hotels that come to the hotel after you stayed last night.

b. If a hotel 'h' is found at more than 'd' distance away from last stayed hotel, then the hotel previous of 'h' is chosen to wait for that night. This is the greedy step, and you stay in this hotel.

c. The process for steps a and b is then repeated until we've reached the last hotel xn.

Running time:

Notice that the worst case occurs if each hotel is at a distance of successive multiples of 'd'. The best move is to estimate the distance to each hotel twice the whole computation in the scenario.

Thus, the total running time that could occur in the worst case is O(2n) = O(n). This is said to be linear time.

You might be interested in
Which of the following websites is least biased
labwork [276]
I think it's D because it's made out of facts. The other ones are more likely to include bias.
8 0
4 years ago
•Should other states wait to see if the high-speed rail system works well before starting their own plans for similar systems?
solmaris [256]
Other states should see how well the system works and also understand how much money it requires for the state to build a high-speed rail system.
7 0
3 years ago
Why is code tracing important when debugging?
larisa [96]

It helps reveal the flow of execution of your program, including results of in-between evaluations. In other words, you can see what your program is doing, and why it takes the decisions it is taking.

If something unexpected happens, the trace will show you the sequence of events that lead to it.

7 0
3 years ago
Who is "TheBrain" He doesn't Give Answers, Or Questions, Keeps liking Profiles and.. Has Thousands of followers.. is he a Mod? ​
ss7ja [257]

Nope, he is a BOT not a MOD. He is made to run for this purpose only. He used to give answers in brainly.in but now he is used for deleting useless answers and questions, to welcome a new user and acts as a server bot.

You can also call "TheBrain" as AI

8 0
3 years ago
By issuing concert tickets on the blockchain, fans can verify transfer of ownership from one digital wallet to another, rather t
MrRa [10]

Answer:

a. double-cross

Explanation:

 Using the blockchain technology in the case of issuing concert tickets solves the problem with double-cross, which is when someone cheats another person who had trusted in them for some transaction. <em>A great asset with blockchain is the transparency with all the transactions because they are registered and cannot be erased or changed.</em>

3 0
3 years ago
Other questions:
  • Which statement reflects inherent bias in reading and learning about our world?
    12·1 answer
  • 2. What are the pros and cons of Toyota structure?
    13·1 answer
  • The sun produces energy by the process of nuclear: <br><br> A.fission <br> B.fusion
    7·2 answers
  • This is a python program.
    6·1 answer
  • If the algorithm does not have instructions for unanticipated results, the computer program will
    15·1 answer
  • Fill in this function that takes three parameters, two Strings and an int. 4- // Write some test function calls here! The String
    9·1 answer
  • Create a static method that: - is called appendPosSum - returns an ArrayList - takes one parameter: an ArrayList of Integers Thi
    6·1 answer
  • Write a program that repeatedly reads in integers until a negative integer is read. The program keeps track of the largest integ
    9·1 answer
  • What software application is most appropriate to use to create multimedia presentations?
    6·2 answers
  • The ________ is the biggest power consumer on a mobile computing device. display CPU memory module hard drive
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!