Data Structures & AlgorithmsHardProduct-company MCQ pattern
LSD radix sort (base 10, stable counting sort per digit) is applied to [170, 45, 75, 90, 802, 24, 2, 66]. What is the array after the FIRST pass (units digit)?
- A. 2 24 45 66 75 90 170 802
- B. 170 90 2 802 24 45 75 66
- C. 802 2 24 45 66 170 75 90
- D. 170 90 802 2 24 45 75 66
Correct answer: D. 170 90 802 2 24 45 75 66
Group by units digit in the original order: 0 → 170, 90; 2 → 802, 2; 4 → 24; 5 → 45, 75; 6 → 66. Stability keeps 802 before 2 (and 170 before 90), so 2 802 is wrong; 802 2 24 … is the result after the second (tens) pass.
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
- What does this function return for a = [1, 3, 3, 3, 5, 7] with x = 3 and with x = 4? python def g(a, x): lo, hi = 0, len(a) - 1 while lo <…
- while (lo <= hi) binary search runs on a sorted array of 31 elements for a key LARGER than every element. How many times does the loop…
- A dynamic array starts with capacity 1 and doubles its capacity (copying all current elements) whenever an insert finds it full. How many…
- A stack-based checker is run on four strings. Which one is balanced?
- A circular queue in an array of size 6 uses front (index of the first item) and rear (index of the next free slot), both starting at 0…
- A 2-D array A[10][20] (indices from 0) of 4-byte integers is stored in COLUMN-major order starting at address 1000. What is the address of…