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
Grace [21]
3 years ago
9

Letm1, m2,···mnbe distinct numbers on the number line, in the increasing order. Your goalis to color all of them blue. You have

magical blue pens with the following property: Whenyou place the pen at co-ordinate x, all the points in the range [x - 5, x + 5] turn blue. Apen can be used only once. Give an algorithm to color all the points using as few pens aspossible. Prove the correctness of the algorithm and derive the runtime.
Computers and Technology
1 answer:
siniylev [52]3 years ago
7 0

Answer:

Following are the algorithm to this question:

y = 0 //  initialize variable y that assigns the value  0

p = 1 // initialize value 1 in the variable p which also known as starting position

init num = 1//define variable num that assign value 1

for j = 1 to n: //defining loop

y = m[j] - m[p]

if (y > 10) //defining if block

num++;  //increment num variable

p=i; //holding loop value in p variable

y= 0//assign value 0 in y variable

Explanation:

Following are the runtime analysis of the above-given algorithm:

The above-provided algorithm is greedy, but if it doesn't exceed the scope, it operates by greedily choosing its next object. Therefore the algorithm selects the fewest number of pens.

Running time:

This algorithm merely iterates once over all the points. The run-time is therefore O(n).

You might be interested in
If you were driving the blue Prius in the situation pictured above, explain why the red Mustang should be given right-of-way at
raketka [301]

Answer:

The red Mustang should be given the right-of-way at this intersection because:

The red Mustang arrived first before the blue Prius and is closer to the stop sign before the arrival of the blue Prius.  This implies that the red Mustang must have waited for its turn, unlike the blue Prius that just arrived at the intersection.

Explanation:

Traffic laws, regulations, and IPDE defensive driving strategy require that drivers always give way to the vehicle that arrived before them at an intersection.   Assuming that multiple vehicles reach the intersection simultaneously, then the vehicle must be given the right-of-way.  Alternatively, the traffic lights at the intersection should be obeyed and be allowed to regulate the movement of vehicles.  IPDE defensive driving strategy requires drivers to be watchful of their driving spaces to determine the appropriate time to move.

8 0
3 years ago
The purpose of a function that does not return a value is
tatuchka [14]

Answer:

The answer to the given question is the option "a".

Explanation:

A function is a block of organized code that provides the reusability of the code. It is used to perform a separate, complex action. In programming languages name is different like, functions, methods, subroutines, procedures, etc. but the working of the function is the same. The purpose of the function that does not return a value is the option "a" and All the options are correct.  

5 0
3 years ago
When the computer is turned on, the operating system is loaded from the hard disk to the _________________. *​
Pavlova-9 [17]

Answer:

The main memory (ROM)

7 0
3 years ago
You can align controls in the report design window using the align button on the report design tools ____ tab.
Iteru [2.4K]
<span>You can align controls in the report design window using the align button on the report design tools arrange tab.</span> This tab is used to apply different types of formatting to reports in Access. The user<span> can change one type of control layout to another,  can remove controls from layouts so that she/he can position the controls wherever you want on the report.</span>
4 0
3 years ago
Why are iterators useful?
Marina CMI [18]
It is d because I said it is
6 0
3 years ago
Other questions:
  • Crowdsourcing is:
    5·1 answer
  • You have no control over who view your post
    10·1 answer
  • You have an old photograph that you want to incorporate in a brochure for your antique business. To convert the photo into digit
    9·2 answers
  • A windows host sends a tcp segment with source port number 1200 and destination port number 25. the sending host is a(n) _______
    10·1 answer
  • In many cases, a subquery can be restated as a/an ______________.
    13·1 answer
  • A spreadsheet has some values entered:Cell A1 contains 10 cell A2 contains, cell A3 contains 7. you enter in cell A4 the followi
    14·2 answers
  • IDPSs can also help the organization protect its assets when its networks and systems are still exposed to ____________________
    9·1 answer
  • Which of the following is not a selection tool in Adobe photoshop
    15·2 answers
  • I need help asap please :) I will mark brainliest for whoever gets the right answer! x
    5·1 answer
  • Help ASAP please This is a skills lab simulation for college, it’s on Microsoft word is there a keyboard shortcut or something o
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!