Question

In: Computer Science

Greedy algorithms. For fractional Snapsack problem, the thief can carry at most 20 pounds. If the...

Greedy algorithms.

  1. For fractional Snapsack problem, the thief can carry at most 20 pounds. If the thief finds the following items: (22 dollars, 7 pounds), (20, dollar, 5 pounds), (50 dollars, 100 pounds), (3 dollar, 1 pounds), (20 dollars, 10 pounds) , and (5 dollars, 0.5 pounds), what should the thief choose?
  2. For the interval scheduling problem, the set of jobs (si, fi) are as follows: (3, 6), (2, 4), (5, 9) (7, 10), (0, 9), (1, 3), (9, 11), and (6, 7). Use the greedy algorithm to give the maximum number of compatible jobs.

Solutions

Expert Solution

Fractional Knapsack

n = 6

w = 20 pounds

Item Weight Value Value/Weight
1 7 22 3.14
2 5 20 4
3 100 50 0.5
4 1 3 3
5 10 20 2
6 0.5 5 10

Sort all the items in decreasing order of their value / weight ratio

I6 I2 I1 I4 I5 I3
10 4 3.14 3 2 0.5

Construct a table with Remaining knapsack weight, Items in kanpsack and total profit obtained

Knapsack Weight Items in Knapsack Profit
20 Ø 0
19.5 I6 5
14.5 I6,I2 25
7.5 I6,I2,I1 47
6.5 I6,I2,I1,I4 50
0 I6,I2,I1,I4,I5(6.5) 50+(6.5*2)

Maximum profit that can be gained is 63 by placing I6,I2,I1,I4 and 6.5 pounds of I5 in the knapsack.

Interval Scheduling

Set of jobs (si, fi) are as follows: (3, 6), (2, 4), (5, 9) (7, 10), (0, 9), (1, 3), (9, 11), and (6, 7)

Job Start Time Finish Time
J1 3 6
J2 2 4
J3 5 9
J4 7 10
J5 0 9
J6 1 3
J7 9 11
J8 6 7

Sort in the descending order of finish time

Job Start Time Finish Time
J6 1 3
J2 2 4
J1 3 6
J8 6 7
J3 5 9
J5 0 9
J4 7 10
J7 9 11

For each job, check if it is overlapping with the previous job i.e., starttime of current job is less than finish time of previous job

Job Start Time Finish Time
J6 1 3

Next, (1,3) and (2,4) are overlapping as 2<3

Job Start Time Finish Time
J6 1 3
J1 3 6
Job Start Time Finish Time
J6 1 3
J1 3 6
J8 6 7

Next, (6,7) and (5,9) are overlapping as 5<7

Next, (6,7) and (0,9) are overlapping as 0<7

Job Start Time Finish Time
J6 1 3
J1 3 6
J8 6 7
J4 7 10

Next, (7,10) and (9,11) are overlapping as 9<10

Hence, the intervals to be considered are (1,3)(3,6)(6,7)(7,10)

Hope it helps! If there are any doubts or discrepancies do comment below! We are available!:) Give your valuable upvote if you are satisfied with the answer!:))))


Related Solutions

A thief robbing a store can carry a maximum weight of W in their knapsack. There...
A thief robbing a store can carry a maximum weight of W in their knapsack. There are n items and ith item weighs wi and is worth vi dollars. What items should the thief take to maximize the value of what is stolen? The thief must adhere to the 0-1 binary rule which states that only whole items can be taken. The thief is not allowed to take a fraction of an item (such as ½ of a necklace or...
What type of problems in supply chain can be addressed by the travelling thief problem?
What type of problems in supply chain can be addressed by the travelling thief problem?
Given the following: - One bus can carry 20 passengers. - One car can carry 2...
Given the following: - One bus can carry 20 passengers. - One car can carry 2 passengers. Provide an application using PHP that calculates the number of buses and cars needed based on a number of passengers entered. You need to also calculate how many passengers will be left after all the full vehicles are determined.
KNAPSACK Optimization Problem using Greedy Method Problem 1: Item Weight Value 1 14 20 2 6...
KNAPSACK Optimization Problem using Greedy Method Problem 1: Item Weight Value 1 14 20 2 6 16 3 10 8 4 5 10 5 4 12 Allowed weight = 24 Kg Problem 2: Item Weight Value 1 6 30 2 8 40 3 15 45 4 22 88 5 25 80 Allowed weight = 60 Kg Problem 3: Item Weight Value 1 6 30 2 8 40 3 15 45 4 22 88 5 25 80 Allowed weight = 60...
A new grain combine with a 20 year life can remove seven pounds of rocks from...
A new grain combine with a 20 year life can remove seven pounds of rocks from its harvest per hour. Any rocks left in the its output hopper will cause $35,000 damage in subsequent processes. Several investments are available to increase the rock-removal capacity, as listed in the table below. If the effective annual rate of return is 8%, what should be done? Note that the $35,000 damage is on an annual basis. For example, if nothing is done (1st...
In Lima one worker can produce either 20 bushels of corn of 5 pounds of tomatoes...
In Lima one worker can produce either 20 bushels of corn of 5 pounds of tomatoes in one day. In Puma one worker can produce either 53 bushels of corn or 7 pounds of tomatoes in one day. The country that specializes in tomato production is willing to sell one pound of tomatoes for at least how many bushels of corn? Round to two decimal places.
20) Which of the following is the most likely problem of supervisors evaluating subordinates? A) focusing...
20) Which of the following is the most likely problem of supervisors evaluating subordinates? A) focusing too much on a single performance standard B) coordinating employee training needs and programs C) being responsible for only one department within the firm D) lacking opportunities to observe the employee's job performance 22) In the current business climate, firms may want to consider evaluating performance more often because ________. A) the law requires that companies conduct performance appraisals often B) changes in the...
Why is capital flight a problem in most developing countries and what can be done to...
Why is capital flight a problem in most developing countries and what can be done to mitigate it? word count is 1000 words
Why is capital flight a problem in most developing countries and what can be done to...
Why is capital flight a problem in most developing countries and what can be done to mitigate it? word count is 1000 words
Problem 5: A researcher wants to see if she can confidently claim that over 20% of...
Problem 5: A researcher wants to see if she can confidently claim that over 20% of YC students plan to transfer to Sac State. She will randomly sample 600 students. She decides to reject H0 if p^ 0.233 where Ha : p> 0.20 . a) For the test she set up, find the probability of making a type II error if the true population proportion is 17%. b) For the test she set up, find the probability of making an...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT