Data Structures & AlgorithmsHardTCS Digital · Infosys SP
LSD radix sort (base 10, stable sort on each digit, units digit first) is applied to [148, 261, 414, 335, 678, 773, 321]. What is the list after the SECOND pass (tens digit)?
- A. [414, 321, 335, 148, 261, 678, 773]
- B. [148, 261, 321, 335, 414, 678, 773]
- C. [414, 321, 335, 148, 261, 773, 678]
- D. [261, 321, 773, 414, 335, 148, 678]
Correct answer: C. [414, 321, 335, 148, 261, 773, 678]
Pass 1 orders by units: [261, 321, 773, 414, 335, 148, 678]. Pass 2 stably orders by tens, so ties keep the units order: [414, 321, 335, 148, 261, 773, 678]. 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
- Items P, Q, R, S, T, U are pushed onto an empty stack in this order, and a pop may happen at any time. Which pop order is NOT possible?
- How many contiguous subarrays of [7, 6, 8, 5, 9, 1, 1, 9, 1, 9] contain exactly 2 odd numbers? (Use exactly(k) = atMost(k) − atMost(k − 1).)
- Longest run of consecutive integers (in any order) using a hash set and starting only from numbers whose predecessor is absent. What is…
- What does this loop-counting code print? (Python) python n, c = 20, 0 i = 1 while i < n: j = i while j < n: c += 1 j = 2 i += 1 print(c)
- An array of 8 integers holds values 1..7 with exactly one value appearing twice: [6, 5, 5, 1, 2, 3, 7, 4]. Treating i → a[i] as a linked…
- Two strings are isomorphic if characters can be replaced one-to-one to turn one into the other. Version A checks both directions; version…