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
Brad Smith works for GHI Firm. GHI firm is a registered Broker-Dealer in State A, B and C and a registered IA in State A. Brad i
Rashid [163]

Answer:

The correct answer is B. This is unacceptable because Brad is not registered in State B

Explanation:

Given:

Brad is a registered Investment Advisory Representative (IAR) in State A.

In the question, it's not stated that Brad is not registered in State B.

Setting up an office in State B is unacceptable because Brad is holding himself out as an IAR in State B and he is not registered as an IAR in State B.

Though GHI is a registered firm in State B, Brad also needs to be registered before setting up an office in other states.

8 0
3 years ago
‘The increased availability of mobile digital devices has had a positive impact on how young people use their free time’. Make a
Law Incorporation [45]
"The increased availability of mobile digital devices has had a positive impact on how young people use their free time."

There are many different views that you could take upon this subject.  

1) You could say that the increased availability of mobile digital devices has allowed children to increase their academic success, by being able to search for and complete assignments using these devices.

2) You could say that the increased availability of mobile digital devices allows for children to occupy themselves by providing games, videos, books, and other things to provide them with entertainment, a learning experience, and more.

Hope this helps!
4 0
3 years ago
What refrigerant has been approved for new household refrigerators and freezers
Alexxx [7]
Bsbsnsnsnsn jajwjemoeododhdhdw whajsjshtzzvsssnxbba. 3
8 0
3 years ago
Any executable files???
Kipish [7]

Doesn't look like there are any..

7 0
3 years ago
Question 1(Multiple Choice Worth 2 points)<br> Which of the following is true of a good photograph?
Rainbow [258]

Answer:

No link but good things about a photgrahp are

Explanation:

Good lighting

Good camra

Good spot

Good zoom

Good focus

4 0
3 years ago
Read 2 more answers
Other questions:
  • Which innovation allowed for the mass production of goods? A. Cotton gin B. Sewing machine C. Industrial lubricator D. Interchan
    6·1 answer
  • Harry needs to use a type of graph in a spreadsheet to show variations in data over a specific period. What type of graph or cha
    11·2 answers
  • Your wireless network has been breached and it seems as though the attacker has modified a portion of your data that is used wit
    12·1 answer
  • IT professionals should help to protect users’ personal information, such as bank account information or Social Security numbers
    14·1 answer
  • The elements of an integer-valued array can be set to 0 (i.e., the array can be cleared) recursively as follows: An array of siz
    14·1 answer
  • In which of the following phases of filmmaking would a production team be focused on the
    10·2 answers
  • Personal statements School leaver
    15·1 answer
  • Name 10 songs of POP SMOKE
    13·1 answer
  • This question involves the creation and use of a spinner to generate random numbers in a game. a gamespinner object represents a
    8·1 answer
  • What is an advantage of using a fully integrated cloud based data analytics platform
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!