Question
Goals: 1. Understanding of the dynamic programming solution to the (one room) weighted interval scheduling problem. 2. Understanding of the five steps for developing a
Goals:
1. Understanding of the dynamic programming solution to the (one room) weighted interval scheduling problem.
2. Understanding of the five steps for developing a dynamic programming solution.
Requirements:
1. Your task is to write a C program to solve the two room weighted interval scheduling problem by using dynamic programming. The first line of the input will be the number of intervals (n) and each of the remaining n lines have three non-negative integers (si, fi, vi) for the start time, finish time, and weight for an interval. The intervals will be ordered by ascending finish time. You should echo the input.
Getting Started:
1. The input should be read from standard input (which will be one of 1. keyboard typing, 2. a shell redirect (
2. Your solution must use dynamic programming to maximize the total weight of the intervals assigned to the two rooms. The intervals assigned to a room may not overlap (two intervals i and j overlap if either si sj fi or si fj fi.).
3. Applying the simple (one room) solution in Notes 7.B to get a maximum solution for one room and then applying again the same technique to the leftover intervals (to assign intervals to the second room) is a non-optimal greedy technique.
4. n will not exceed 50.
5. You should print your dynamic programming table(s) with appropriate labeling.
6. Your solution should be formatted as:
a. A line with just the number of intervals assigned to the first room.
b. A line for each of the intervals assigned to the first room: start time, finish time, weight.
c. A line with just the number of intervals assigned to the second room.
d. A line for each of the intervals assigned to the second room: start time, finish time, weight.
e. A line with the total weight that has been achieved
and appear at the end of your output. No particular ordering of the intervals is required.
Input (a):
9 1 2 1 1 3 3 2 4 1 3 5 1 4 6 2 5 7 1 6 8 2 7 9 1 8 10 2
Output (a):
9 1 2 1 1 3 3 2 4 1 3 5 1 4 6 2 5 7 1 6 8 2 7 9 1 8 10 2 5 1 2 1 2 4 1 4 6 2 6 8 2 8 10 2 4 1 3 3 3 5 1 5 7 1 7 9 1 14
Input (b):
16 10 20 1 15 25 2 10 30 3 20 40 1 15 45 2 30 50 1 40 60 2 25 65 3 50 70 1 35 75 3 60 80 2 15 85 4 70 90 1 35 95 3 80 100 2 72 110 3
Output (b):
16 10 20 1 15 25 2 10 30 3 20 40 1 15 45 2 30 50 1 40 60 2 25 65 3 50 70 1 35 75 3 60 80 2 15 85 4 70 90 1 35 95 3 80 100 2 72 110 3 3 15 25 2 25 65 3 72 110 3 4 10 30 3 40 60 2 60 80 2 80 100 2 17
Input (c):
16 10 20 4 15 25 4 10 30 2 20 40 4 15 45 3 30 50 4 40 60 3 25 65 2 50 70 4 35 75 2 60 80 3 15 85 1 70 90 4 35 95 2 80 100 3 72 110 2
Output (c):
16 10 20 4 15 25 4 10 30 2 20 40 4 15 45 3 30 50 4 40 60 3 25 65 2 50 70 4 35 75 2 60 80 3 15 85 1 70 90 4 35 95 2 80 100 3 72 110 2 5 10 20 4 20 40 4 40 60 3 60 80 3 80 100 3 4 15 25 4 30 50 4 50 70 4 70 90 4 33
2 1 8 2 1 6 2 1 1 3 1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started