Data Structures & AlgorithmsHardGATE CS · CAT · MBA placement
Items as (weight, value) are [(10, 60), (20, 100), (30, 120)]. You may take any FRACTION of an item. The capacity is 50. What is the maximum total value? (Give the exact value; it may be fractional.)
- A. 220
- B. 240
- C. 280
- D. 244
Correct answer: B. 240
Fractional knapsack: sort by value per weight (60/10 = 6, 100/20 = 5, 120/30 = 4), take whole items while they fit and a fraction of the next one. The 0/1 version cannot split items, so it gives a smaller value here.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- Five jobs (processing time, due date) are [(4, 9), (2, 6), (6, 12), (3, 7), (5, 10)]. They run one at a time with no preemption, starting…
- Stalls are at positions [1, 2, 8, 4, 9, 15, 17] on a line. You must place C = 4 cows in distinct stalls to maximise the MINIMUM distance…
- Books have page counts [12, 34, 67, 90, 25, 40, 18] in this fixed order. They are split among K = 3 students so that each student receives…
- Koko has banana piles [3, 6, 7, 11] and H = 8 hours. Each hour she eats up to k bananas from ONE pile (if a pile has fewer, she finishes…
- For the array [19, 4, 33, 12, 7, 29], find the smallest positive integer d such that the sum of ceil(x / d) over all elements is at most…
- In a 3 × 5 multiplication table (entries i × j for 1 ≤ i ≤ 3, 1 ≤ j ≤ 5), with repeats counted, what is the 7-th smallest entry?