GATE Computer ScienceHardGATE CS (PYQ pattern)
Items 0.5, 0.7, 0.5, 0.2, 0.4, 0.2, 0.5, 0.1, 0.6 (in this order) are packed into bins of capacity 1 by Next-Fit, First-Fit and First-Fit-Decreasing (FFD sorts the items in non-increasing order first). How many bins do they use, as (NF, FF, FFD)?
- A. (6, 5, 5)
- B. (6, 5, 4)
- C. (5, 5, 4)
- D. (6, 4, 4)
Correct answer: B. (6, 5, 4)
NF: {0.5}, {0.7}, {0.5, 0.2}, {0.4, 0.2}, {0.5, 0.1}, {0.6} → 6. FF: {0.5, 0.5}, {0.7, 0.2, 0.1}, {0.2, 0.4}, {0.5}, {0.6} → 5. FFD on 0.7, 0.6, 0.5, 0.5, 0.5, 0.4, 0.2, 0.2, 0.1: {0.7, 0.2, 0.1}, {0.6, 0.4}, {0.5, 0.5}, {0.5, 0.2} → 4, which is optimal since the total is 3.7.
More Algorithms questions
- Longest-Processing-Time-first scheduling puts jobs, in non-increasing order of length, on the currently least loaded machine. For jobs of…
- For the string s = abaababaabaab (13 characters), a number p (1 ≤ p ≤ 13) is called a period if s[i] = s[i + p] for every valid i (p = 13…
- Boyer–Moore majority vote (candidate c and counter k; if k = 0 take the current element as c with k = 1; else increment k when equal and…
- In the Josephus problem 30 people numbered 1 to 30 stand in a circle; counting starts at person 1 and every third person is eliminated (3…
- Quicksort partitions m elements with exactly m − 1 comparisons and then recurses on the two sides (sizes k and m − 1 − k). Over all inputs…
- Keys 50, 30, 70, 20, 40, 60, 80 are inserted in this order into an empty binary search tree. How many of the 7! insertion orders of these…