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
The process of making raw materials into a finished product is known as
Olin [163]
1.) Business Engineering or Manufacturing :)
<span />
6 0
2 years ago
Read 2 more answers
Which of the following components does a typical two stroke engine contain
Vlada [557]
It is B- An L-type cylinder head. 
4 0
2 years ago
Read 2 more answers
PLEASE PLEASE PLEASE HELP!! WILL GIVE A BRAINLIEST IF UR RIGHT!!
Nataly_w [17]
1. spreadsheet
2. Computers will continue to become smaller in size and become faster

3 0
2 years ago
What names of websites of presentation or visualization <br>​
Fittoniya [83]

Explanation:

Google Slides. Google has made a conscious effort to emulate many of MS Office's tools, and Slides is their alternative to PowerPoint. ...

DesignBold. ...

PowToon. ...

Slides. ...

ClearSlide. ...

Moovly. ...

Prezi. ...

KnowledgeVision.

5 0
3 years ago
Which key should you press to leave the cell as it originally was?
GREYUIT [131]
The correct answer should be A. Delete
4 0
3 years ago
Other questions:
  • Jameis is researching at his local library when he finds a perfect source to use in his paper. When he goes to check the book ou
    12·2 answers
  • What will be the output of “AAAAMMMMMHHHVV” using a file compression technique?
    9·2 answers
  • What's a good app that solves trigonometry problems?
    8·1 answer
  • Where can you find your EFC
    8·2 answers
  • In the code segment below, assume that the int variable n has been properly declared and initialized. The code segment is intend
    5·1 answer
  • What is the code name for the 12 engineers who developed the ibm pc?
    8·1 answer
  • Which 3D game has Bentley the Bear collect gems while avoiding enemy trees, bees, ghosts, skeletons, and Berthilda the witch?
    9·1 answer
  • When you pass a double variable to a method, the method receives ______.a) a copy of the memory addressb) the reference of the v
    12·1 answer
  • Were can i watch unexpected free season 3
    9·1 answer
  • What Is The First Computer Brought In Nepal ? <br>​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!