GATE Computer ScienceHardGATE CSE · ISRO

A singly linked list holds 1, 2, …, 11 in order. Step 1: reverse it in consecutive groups of 4 nodes (a final group with fewer than 4 nodes is left as it is). Step 2: delete every node whose value is a multiple of 3. Step 3: reverse the whole list. What is the 5th value from the head of the final list?

  1. A. 7
  2. B. 8
  3. C. 1
  4. D. 5

Correct answer: B. 8

After step 1: 4 3 2 1 8 7 6 5 9 10 11; after step 2 and the full reversal the list is 11 10 5 7 8 1 2 4, whose 5th value is 8.

More Programming and Data Structures (GATE) questions

Exams that ask this topic