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 is the role of computer in modern problem solving​
REY [17]

Answer:

Una computadora es una herramienta muy básica para hacer tareas repetitivas de forma más eficiente. Una computadora no es capaz de analizar un problema y obtener una solución.

Explanation:

3 0
3 years ago
A videogame designer would be most interested in the _____ elements of beowulf.
adelina 88 [10]
I think he would be interested in a. epic elements of beowulf.
5 0
3 years ago
Read 2 more answers
A network technician cannot get a host to connect to the internet. running the ping command shows the apipa ip address. what is
Lunna [17]
The router will not connect to th network. This will keep it from connecting to the NEXUS
6 0
3 years ago
Using the FAFSA form , you can for apply for what
AlladinOne [14]

apply for financial aid for college or grad school.

7 0
3 years ago
Read 2 more answers
The femur is _____.<br><br> part of a cell<br> the thigh bone<br> a hair follicle<br> a muscle
MA_775_DIABLO [31]

Its the Thigh Bone. Hope this helps. =^-^=

7 0
3 years ago
Other questions:
  • The ________ model allows the owner of a resource to manage who can or cannot access the item. Owners maintain this access throu
    8·1 answer
  • File Explorer contains ribbon tabs that can be used for various functions. Which ribbon tab provides options to open a new File
    11·1 answer
  • Suppose the file is sent continuously as one big message. how long does it take to send the file, assuming it is sent continuous
    15·1 answer
  • What do developers do to support software products? explain to users which development process model was used to make the produc
    8·1 answer
  • Universal Container sales reps can modify fields on an opportunity until it is closed. Only the sales operations team can modify
    13·1 answer
  • Which attribute of the image tag specifies the URL of an image
    14·1 answer
  • Small data files that are deposited on a user's hard disk when they visit a website are called _______.
    6·2 answers
  • For a parking application that lets you pay for parking via your phone, which of these is an example of a functional requirement
    8·1 answer
  • Which of the following tells the computer hardware what to do? A Information B) Software Procedures D People
    12·2 answers
  • Which of the following is the most significant result of technological innovation?
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!