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
What came first, the internet or WIFI?
horsena [70]

Answer: wifi

Explanation:

because you can't have the internet if you don't have wifi to power it up

4 0
3 years ago
Question 1<br> What does the % find?<br> The product<br> The mode<br> The quotient<br> The remainder
Paul [167]
The correct answer is the remainder
7 0
4 years ago
In which state of matter is there no particle motion?
kiruha [24]
Solid is your answer for the day
6 0
3 years ago
The website’s________ section will enable Lana to add her company website name and logo to the top of every page of the website.
Delicious77 [7]

It is the header section of the website.

5 0
3 years ago
What is the best AI app used in education?
goblinko [34]

Answer:

Khan Academy is the best app for education, you can watch videos and do quizes

5 0
3 years ago
Other questions:
  • Jackson is teaching the decimal number system. He wants his students to know how to expand numbers by powers of 10. Which is the
    13·2 answers
  • You can view the existing Access Control Lists for a set of folders on a Windows system by right-clicking the folder you want to
    10·1 answer
  • The activities that gather information about the organization and its network activities and assets is called fingerprinting. __
    14·1 answer
  • Which shortcut key in Microsoft Word 2016 will launch Spell Checker?
    5·2 answers
  • Given the following: int funcOne(int n) { n *= 2; return n; } int funcTwo(int &amp;n) { n *= 10; return n; } What will the follo
    15·1 answer
  • What are some ways you can work with templates? Check all that apply.
    9·2 answers
  • Select all the lines that have a slope of 5/2
    13·1 answer
  • Write the code to produce a for loop that counts down from 20 to 0 by 2’s and prints the number each time it goes through the lo
    15·1 answer
  • Which are examples of digital video? Choose all that apply.
    6·2 answers
  • The short-range two-way communication technology behind contactless payments is called ____.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!