Data Structures & AlgorithmsHardGATE CS · TCS NQT
Three jobs given as (processing time, weight) are (3, 2), (1, 4), (2, 1). They run one at a time from time 0. What is the minimum possible sum of weight times completion time?
- A. 20
- B. 18
- C. 17
- D. 12
Correct answer: B. 18
Smith's rule orders jobs by processing time divided by weight, which is an adjacent-exchange argument. Ordering by processing time alone (or by weight alone) can be suboptimal.
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
- How many integers from 1 to 200 inclusive have exactly 3 positive divisors?
- How many contiguous subarrays of [3, 1, 2, 5, 4, 6] consist of distinct consecutive integers (in any order)?
- What is the length of the shortest contiguous subarray of [1, 2, 3, 1, 2, 4, 3] that contains every distinct value present in the array?
- How many integers from 1 to 200 inclusive are palindromes when written in decimal?
- How many index pairs i < j in [3, 5, 6, 9, 10] have a[i] XOR a[j] with an odd number of 1-bits?
- What is the minimum number of swaps of any two positions needed to make [2, 1, 2, 1, 3, 3, 1] sorted in non-decreasing order?