Professional Documents
Culture Documents
A002 Aagam Ratadia Exp3 DAA
A002 Aagam Ratadia Exp3 DAA
Experiment 3
Name: Aagam Ratadia SAP ID: 60017220112
Date: 29/2/2024
Aim Given a set of tasks with their respective start and finish times, the task is to
select the maximum number of non-conflicting tasks that can be performed
by a single person or machine within a given time frame. Two tasks are said
to be conflicting if they overlap with each other, i.e., if one task starts before
the other finishes. The objective is to find an optimal solution that
maximizes the number of tasks selected, ensuring that no two selected tasks
conflict with each other.
Software Turbo C
Pre- Activity Selection Problem
requisite
Theory The Activity Selection Problem is an optimization problem
which deals with the selection of non-conflicting activities that
needs to be executed by a single person or machine in a given
time frame.
Step 2: Select the first activity from sorted array act[] and add it
to sol[] array.
Algorithm
Activity Selection Problem Example
5 9 a1
1 2 a2
3 4 a3
0 6 a4
5 7 a5
8 9 a6
1 2 a2
3 4 a3
0 6 a4
5 7 a5
5 9 a1
8 9 a6
{
// Sort activities according to finish time
sort(arr, arr+n, Sort_activity);
// Driver program
int main()
{
Activity arr[N];
for(int i=0; i<=N-1; i++)
{
cout<<"Enter the start and end time of "<<i+1<<" activity
\n";
cin>>arr[i].start>>arr[i].finish;
}
print_Max_Activities(arr, N);
return 0;
}
Department of Artificial Intelligence and Machine Learning
B.Tech. Sem: IV Subject: Data Analysis and Algorithm Lab
Result
Conclusion
Time Complexity Analysis
problem:
Write Ups: