Data Structures & AlgorithmsHardTCS NQT · Infosys
Stable partition of the list [1, 4, 3, 2, 5, 2] around x = 4 puts every node with value < 4 first, then every node with value >= 4, keeping the relative order inside each group. What value is at position 3 of the result (1-based)?
- A. 2
- B. 3
- C. 1
- D. 4
Correct answer: A. 2
The small group is 1, 3, 2, 2 and the large group is 4, 5. Keeping relative order is the point, so the first group is not sorted.
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
- Asteroids move in a row; positive values move right and negative values move left, and when two meet the one with the smaller absolute…
- Daily temperatures are 73, 74, 75, 71, 69, 72, 76, 73. For each day, the wait is the number of days until a warmer day (0 if none). What…
- An array [2, 3, 1, 1, 4] gives the maximum forward jump from each index. Starting at index 0, what is the minimum number of jumps needed…
- There are 100 bulbs, all off. For each i from 1 to 100, pass i toggles every bulb whose number is a multiple of i. How many bulbs are on…
- What is the smallest positive integer x such that 180 x is a perfect cube?
- How many trailing zeros does 100! have when written in base 6?