Skip to content

Latest commit

 

History

History
34 lines (29 loc) · 1.39 KB

README.md

File metadata and controls

34 lines (29 loc) · 1.39 KB

Activity-Selection-Problem

This is a problem taken from my Lab Mentor.

Problem Statement

Here, A teacher is looking to take some courses, where he will be paid a charge for every courses (No variations in charges for any durations of the courses). But he is wanting to select the courses that has more duration. Again, he is willing to take the maximum no. of courses for his own financial betterment. It is asked to help him finding the optimal solution to his problem by using Activity Selection Algorithm.

Things that is asked as INPUT:

  • At-first the charge for a courses have to be inputed.
  • Then the number of courses will be asked.
  • After that, the name of each activity with the starting time and the duration have to be inputed.

Things that is asked as OUTPUT:

  • Make a list of courses inputed in name-start-finish manner.
  • Each task will have a name that will be a character like a, b, c etc. The output will print the courses sequencially that are selected. Also, select the courses that has more duration and also take the maximum no. of courses.
  • Lastly, calculate the revenue that he will earn if he takes the outputed courses.

Examples

  • Input:
    10
    4
    a 2 3
    b 4 2
    c 7 1
    d 8 2

  • Output:
    Name: a, Start: 2, Finish: 5
    Name: b, Start: 4, Finish: 6
    Name: c, Start: 7, Finish: 8
    Name: d, Start: 8, Finish: 10
    Selected Activities:
    b
    d
    The profit: 20