Data Structures & AlgorithmsModerateTCS NQT · Infosys
Problem: A queue of 5 customers arrives with service times 4, 2, 6, 1, 3. A single server processes them in order (first come first served). What is the average waiting time before service starts, rounded down to an integer?
- A. 10
- B. 4
- C. 7
- D. 8
Correct answer: C. 7
Waits are 0, 4, 6, 12, 13, totalling 35, so the average is 7. Including service times (turnaround) gives 10, shortest-job-first gives 4, and dividing by 4 instead of 5 gives 8.
More Coding Interview Problems questions
- Problem: Starting with the list [3, 8, 2, 5], repeatedly take the last two elements, replace them by their difference (larger minus…
- Problem: How many 3-digit numbers (100–999) have digits that form a strictly increasing sequence when read left to right?
- Problem: In a list of the first 30 positive integers, how many numbers are multiples of 2 or 3 but not of 6?
- Problem: For the array [6, 1, 8, 3, 7], find the minimum number of adjacent swaps needed to sort it in increasing order (adjacent swaps…
- Problem: Starting at the number 2, repeatedly apply f(x) = x² + 1 modulo 11. What is the value after 5 applications?
- Problem: The array [2, 3, 4, 5, 6, 7, 8] is examined for the number of subsets whose sum is a perfect square (the empty subset has sum 0…