Question

Consider the following activities. Solve the probl

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The algorithm for ativity selection problem:

  • Sort the activities according to their finishing time
  • Select the first activity from the sorted array and print it.
  • Do following for remaining activities in the sorted array.
  • .a) If the start time of this activity is greater than the finish time of previously selected activity then select this activity and print it.

The solution to above problem:

step 1: sort the activities according to their finish time

i 2 3 1 5 4 6
si 1 3 0 5 5 8
fi 2 4 6 7 9 9

Step 2: select the first activity and print it

output : 2

Step 3: si(activity(3)) > fi(activity(2)

output: 2,3 and repeat the steps,

si(activity(1)) < fi(activity(3))

output: 2,3

si(activity(5))>fi(activity(3))

output : 2,3,5

finally si(activity(6))>fi(activity(5))

so output: 2,3,5,6

so ,the activities that are selected are 2,3,5,6

Add a comment
Know the answer?
Add Answer to:
Consider the following activities. Solve the problem of activity-selection problem.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT