Varendra University Dept. of CSE: Course Title: Algorithms Lab Course Code: CSE 226
Varendra University Dept. of CSE: Course Title: Algorithms Lab Course Code: CSE 226
Varendra University Dept. of CSE: Course Title: Algorithms Lab Course Code: CSE 226
Varendra University
Dept. of CSE
Lab Report-03
Course Title : Algorithms Lab
Course Code : CSE 226
Submitted By Submitted To
Name : MD. Arnob Mustakim Tokey Ahmmed
ID : 201311015 Lecturer
Semester : 5th Dept. of CSE
Section : A Varendra University
Dept. of CSE, Md. Mosiur Rahman
Varendra University Sweet
Lecturer (Provisional)
Dept. of CSE
Varendra University
Signature
Suppose S = {1, 2....n} is the set of n proposed activities. The activities share
resources which can be used by only one activity at a time,Tennis Court, Lecture
Hall, etc. Each Activity "i" has Start Time(st) and a Finish Time(ft), where st≤ft. If
selected activity "i" take place meanwhile the half-open time interval [st,ft).
Activities i and j are compatible if the intervals (st, ft) and [st, ft) do not overlap (i
and j are compatible if st ≥ft or st ≥ft). The activity-selection problem chosen the
maximum- size set of mutually consistent activities.
1. #include<bits/stdc++.h>
2. using namespace std;
3.
4. class Activity
5. {
6. public:
7. int id,start,finish;
8. Activity(int id, int start, int finish)
9. {
10. this->id = id;
11. this->start = start;
Output:
1. #include <bits/stdc++.h>
2. using namespace std;
3.
4. class Knapsack
5. {
6. public:
7. int id;
8. int value;
9. int weight;
10. Knapsack(int id, int value, int weight)
11. {
12. this->id = id;
13. this->value = value;
14. this->weight = weight;
15. }
16. };
17.
18. int main()
19. {
20. Knapsack* ks;
21.
22. multimap<int,Knapsack*, greater<int> >mp;
23. map<int,Knapsack*>::iterator it;
24.
25. freopen("knapsack.txt","r",stdin);
26.
27. int products,bag_size;
28. cin >> products >> bag_size;
29.
30. int value,weight;
Output: