Computer Science EngineeringVery hard

A singly linked list holds 1->2->3->4->5. After: p=head; while(p->next && p->next->next) p=p->next->next; what is p->data?

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

Correct answer: A. 5

p moves 1 -> 3 -> 5, and at 5 the loop stops because p->next is NULL.

More Algorithms, Data Structures & Programming (ISRO CS) questions

Exams that ask this topic