Data Structures & AlgorithmsHardGATE CS · Product placement
LSD radix sort (base 10, stable sort on each digit, units digit first) is applied to [134, 461, 324, 794, 742, 141, 668]. What is the list after the SECOND pass (tens digit)?
- A. [324, 134, 742, 141, 461, 668, 794]
- B. [461, 141, 742, 134, 324, 794, 668]
- C. [134, 141, 324, 461, 668, 742, 794]
- D. [324, 134, 141, 742, 461, 668, 794]
Correct answer: D. [324, 134, 141, 742, 461, 668, 794]
Pass 1 orders by units: [461, 141, 742, 134, 324, 794, 668]. Pass 2 stably orders by tens, so ties keep the units order: [324, 134, 141, 742, 461, 668, 794]. Sorting by tens alone, ignoring pass 1, loses that tie order.
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 is the length of the smallest substring of "baddcacdabcbd" that contains every distinct character of the string at least once?…
- A circular queue in an array of size 7 keeps one slot empty to tell full from empty (front = rear means empty; (rear + 1) mod 7 = front…
- A fixed sliding window of length 5 moves over "programmingisfun". What is the maximum number of vowels (a, e, i, o, u) inside any window?
- How many contiguous subarrays of [4, 2, 2, 6, 4, 1, 5] have bitwise XOR equal to 6? (Prefix XORs with a frequency map: add freq[px ^ 6] at…
- What is the minimum number of characters that must be APPENDED to the end of "abacdcab" to make it a palindrome? (Find the longest…
- For [7, 3, 5, 3, 7, 2, 5], definition A returns the element whose FIRST occurrence is earliest among all repeating elements; definition B…