Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. Brian Kernighan

Selection problem

Language Java | Level Intermediate | Category Algorithms | August 5, 2015 7:32 am


Algorithm Problem Description

An activity-selection is the problem of scheduling a resource among several competing activity. It is a mathematical optimization problem concerning the selection of non-conflicting activities to perform within a given time frame, given a set of activities each marked by a start time and finish time.

The problem is to select the maximum number of activities that can be performed by a single person or machine, assuming that a person can only work on a single activity at a time. Write a program to activity selection problem?

Output

          	        
          	        

Array 1 items : [1, 3, 0, 5, 8, 5]
Array 2 items : [2, 4, 6, 7, 9, 9]
Following activities are selected
0 th Acticivity is selected which has start time of [1] and finish time of [2]
1 th Acticivity is selected which has start time of [3] and finish time of [4]
3 th Acticivity is selected which has start time of [5] and finish time of [7]
4 th Acticivity is selected which has start time of [8] and finish time of [9]

          	        
          	        				    


Comments



Please login to add comments.