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 type of multiplexing divides transmission opportunities into slots of 125 microseconds with position inside each slot rese
Zinaida [17]

Answer: Time division multiplexing

Explanation: because a slot is equivalent to 125ms

And each position inside a slot is for each signal and a single bit frim each voice conversation is sent during each 125ms slot

7 0
3 years ago
Using the C language, write a function that accepts two parameters: a string of characters and a single character. The function
Sav [38]

Answer:

#include <stdio.h>

void interchangeCase(char phrase[],char c){

  for(int i=0;phrase[i]!='\0';i++){

      if(phrase[i]==c){

          if(phrase[i]>='A' && phrase[i]<='Z')

              phrase[i]+=32;

          else

              phrase[i]-=32;      

      }

  }

}

int main(){

  char c1[]="Eevee";

  interchangeCase(c1,'e');

  printf("%s\n",c1);

  char c2[]="Eevee";

  interchangeCase(c2,'E');

  printf("%s\n",c2);    

}

Explanation:

  • Create a function called interchangeCase that takes the phrase and c as parameters.
  • Run a for loop that runs until the end of phrase and check whether the selected character is found or not using an if statement.
  • If the character is upper-case alphabet, change it to lower-case alphabet and otherwise do the vice versa.
  • Inside the main function, test the program and display the results.
8 0
3 years ago
8. SQL, Oracle Report, and Visual Basic are all examples under the
sleet_krkn [62]

SQL, Oracle Report, and Visual Basic are all examples under the generation.

<h3>Fourth generation languages</h3>

Fourth-generation programming language (4GL) are computer programming language based on the advancement on third-generation programming languages (3GL).

4GLs may include support for <em>database management, report generation, mathematical optimization, GUI development, web development.</em>

SQL, Oracle Report, and Visual Basic are all examples under the generation.

Find out more on Fourth generation languages at: brainly.com/question/9325849

3 0
2 years ago
Which option correctly identifies the expense that will cost you the most when you are living on your own?
larisa86 [58]
Cccccccccccccccccccccc
5 0
3 years ago
What is a system of computers that are joined together and connect to peripheral devices and can’t be accessed from home
harina [27]
<span>What is a system of computers that are joined together and connect to peripheral devices and can’t be accessed from home = LAN for Local Area Network, unless it's connected to the internet and you allow VPN/RAS system access you will not be able to connect to a LAN remotely.</span>
7 0
3 years ago
Other questions:
  • Semiconductor memory is used mainly for primary storage even with its high cost. In another hand, the magnetic tape is the cheap
    9·2 answers
  • What was the impact of the rise of the Japanese auto industry and the semiconductor industry in south eastern​ Asia? A. It incre
    13·1 answer
  • Match the job titles to the tasks
    11·2 answers
  • PowerPoint provides a wide variety of predefined shapes that can add visual insert to a slide true or false
    10·2 answers
  • Solve a single producer, single consumer problem using wait() and notifyAll(). The producer must not overflow the shared buffer,
    5·1 answer
  • Which os the following is NOT true about the proof of work concept?
    8·1 answer
  • S.B. manages the website for the student union at Bridger College in Bozeman, Montana. The student union provides daily activiti
    7·1 answer
  • What do you call a collection of pre-programmed commands and functions used in programs?
    10·1 answer
  • PLEASE HELP! (NO LINKS)
    7·1 answer
  • Why does rating an incorrect answer as 1 star raise its score on brainly?
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!