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
Tribology is a branch of physics concerned with friction in mechanical motion. Knowledge of tribology would be useful working wi
katovenus [111]

Answer: C conventional hard disk drives

Explanation: hope this helps! (:

4 0
3 years ago
Can somebody hack ur account on Brainly bc I feel like I have bc I have answered waaaaaay more questions than shows on my profil
QveST [7]
It says you’ve only answered 11, but yeah it you’re account CAN be hacked
4 0
2 years ago
A _____ attack floods a network or server with service requests to prevent legitimate users' access to the system. phishing back
Ad libitum [116K]
Denial-of-service is correct 
4 0
3 years ago
True or false: Sony is the company behind the creation of the ‘Super Mario Bros.' franchise.
Volgvan

False. It was Nintendo behind the creation of Super Mario Bros.

6 0
3 years ago
Read 2 more answers
Write a program that declares and initializes a variable representing the weight in milligrams from the keyboard. The program di
Burka [1]

Answer:

weight = int(input("Enter weight in milligrams: "))

kilograms = int(weight / 1000000)

grams = int((weight - (kilograms * 1000000)) / 1000)

milligrams = weight - ((kilograms * 1000000) + (grams * 1000))

print("{} milligrams are equivalent to {} kilogram(s), {} gram(s), and {} milligram(s)".format(weight, kilograms, grams, milligrams))

Explanation:

*The code is in Python.

Ask the user to enter the weight and set it to the variable weight

Calculate the kilograms, divide the weight by 1000000 and cast the result to the int (If the weight is 1050042, kilograms would be 1050042/1000000 = 1)

Calculate the grams, subtract the kilograms from the weight, divide it by 1000 and cast the result to the int (If the weight is 1050042, grams would be int((1050042 - (1 * 1000000)) / 1000) = 50)

Calculate the milligrams, subtract the kilograms and grams from the weight (If the weight is 1050042, milligrams would be 1050042 - ((1 * 1000000) + (50 * 1000)) = 42)

Print the weight, kilograms, grams, and milligrams in the required format

3 0
3 years ago
Other questions:
  • It is essential that a security professional is able to resolve and respond to cyber law inquiries and incidents while avoiding
    14·1 answer
  • Phoebe has to give a permission about recycling. Where should she look while presenting?
    11·1 answer
  • What feature of a word processing program helps you to easily check and correct spelling mistakes?
    9·1 answer
  • All of the following are ways to limit what is tracked about you online, except:
    12·1 answer
  • What is the definition of posture<br>​
    7·1 answer
  • PAGE<br>DATE<br>0 What types of information should be there internet?​
    5·1 answer
  • Select one type of mobile phone connectivity you can use to stream videos on a smartphone
    10·2 answers
  • Examples of system software include operating systems like macos, Linux, Android and
    10·2 answers
  • Which of these is a negative effect of computer technology's role in creating
    9·1 answer
  • Write A Code In Python
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!