Data Structures & AlgorithmsHardGATE CS · TCS NQT
A list holds 1, 2, 3, 4, 5. It is rotated right by 2 positions (the last two nodes move to the front). What is the value of the new head node's successor (the node at position 2)?
- A. 6
- B. 7
- C. 9
- D. 5
Correct answer: D. 5
After rotating right by 2 the list is 4, 5, 1, 2, 3, so position 2 holds 5. Rotating left by 2 would instead give position 2 as 3.
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
- How many pairs x < y with 1 <= x, y <= 12 have (x + y) dividing x y exactly?
- How many distinct values does floor(30 / k) take as k ranges over 1 to 30?
- How many triples a < b < c with a, b, c in [1, 10] satisfy a + b = c?
- What is the minimum number of characters that must be deleted from aabbaa so that no two adjacent characters of the remaining string are…
- How many distinct strings can be obtained from aabb by removing exactly one character?
- What is the sum of the decimal digits of 100!?