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
RUDIKE [14]
3 years ago
13

You are running an art museum. There is a long hallway with k paintings on the wall. The locations of the paintings are l1, ...,

lk . These locations are real numbers, but not necessarily integers. You can place guards at locations in the hallway, and a guard can protect all paintings within 1 unit of distance from his location. The guards can be placed at any location, not just a location where there is a painting. Design a greedy algorithm to determine the minimum number of guards needed to protect all paintings.
Computers and Technology
1 answer:
Airida [17]3 years ago
3 0

Answer:

The answer to the algorithm is given below:

Explanation:

Algorithm:

#Define a set to keep track of the locations of the paintings.

location = {l1, l2, l3, l4, …, lk}

#Sort the set of locations.

Sort(location)

#Define a set to keep track of the positioned guards.

set P = {NULL}

#Define a variable to keep track of

#the location of the guard last positioned.

curr_guard = -infinity

#Define a variable to access the

#locations of the paintings.

i = 0

#Run the loop to access the

#location of the paintings.

#Since the location set has been sorted, the paintings

#are accessed in the order of their increasing locations.

while i < k:

#Check if the current painting is

#not protected by the current guard.

if location(i) > curr_guard + 1:

   

   #Assign a guard to

   #protect the painting.

   curr_guard = location(i) + 1

   

   #Add the guard to the set

   #of the positioned guards.

   P = P + {curr_guard}

#Increase the value of

#the variable i by 1.

i = i + 1

#Define a variable to count

#the number of guards placed

count = 0

#Run the loop to count

#the number of guards.

for guard in P:

count = count + 1

#Display the number of guards

#required to protect all the paintings.

print ("The minimum number of guards required are: ", count)

You might be interested in
Ethics issues are significant in the area of online privacy because laws have not kept pace with the growth of the Internet and
raketka [301]

Answer:

The answer is "True"

Explanation:

In the given statement some information is missing that is "True or false"

Internet security is the scope of the privacy and security of the electronic exchange of data. It's a common term that refers to something like many factors, technologies, and technology used to protect records, contact, and interests, confidential and private.

  • The security of the Internet is recognized as the privacy of the User.
  • It is secure and unique passphrases or two-factor authentication.
7 0
3 years ago
What is a computer?<br>please solve with explaining ​
ivann1987 [24]

Answer:

computer is a device for storing and processing data and also to communicate with people

5 0
2 years ago
EXERCISE
nirvana33 [79]

Answer:

1. True

2. True

3. False

4. True

5. True

8 0
2 years ago
To employ an access key, press and hold down the ____ key as you tap the access key.
Veronika [31]
To employ an access key, press and hold down the Alt key as you tap the access key.
4 0
3 years ago
Help! Will give Brainly Explain what input, output, storage, and processing are in relation to computer functions.
stepladder [879]

Answer:

<em><u>please</u></em><em><u> </u></em><em><u>mark</u></em><em><u> </u></em><em><u>as</u></em><em><u> </u></em><em><u>brainliest</u></em><em><u> </u></em>

Explanation:

To function, a computer system requires four main aspects of data handling: input, processing, output, and storage. The hardware responsible for these four areas operates as follows: Input devices accept data in a form that the computer can use; they then send the data to the processing unit.

3 0
3 years ago
Other questions:
  • _____________ data is what is translated to digital format so it can be stored in a computer.
    10·1 answer
  • You have just installed a new NIC in your PC to replace the old one that had started malfunctioning. What additional software mu
    15·1 answer
  • When pointed over a text within a paragraph, the cursor takes the shape of a/an
    10·1 answer
  • The ________ utility automatically creates duplicates of your libraries, desktops, contacts, and favorites to another storage lo
    6·1 answer
  • Write a program that inputs a five-digit integer, spearates the integer into its digits and prints them seperated by three space
    6·1 answer
  • Math and science are the foundation from which drafters work<br><br> True<br> False
    8·1 answer
  • Is pseudocode obtained from Algorithm or is Algorithm obtained from pseudocode?
    8·1 answer
  • Working mechanism of computer ​
    10·1 answer
  • Indicate if the statement is true or false False 1. A spreadsheet cannot recalculate after you have changed data in your workshe
    15·1 answer
  • The project objective is the detailed description of the characteristics of the project. True or False?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!