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?
- A. 5
- B. 3
- C. 4
- D. 1
Correct answer: A. 5
p moves 1 -> 3 -> 5, and at 5 the loop stops because p->next is NULL.
Practise more Algorithms, Data Structures & Programming (ISRO CS) questionsAlgorithms, Data Structures & Programming (ISRO CS): notes and key points
More Algorithms, Data Structures & Programming (ISRO CS) questions
- The number of leaf nodes in a perfect binary tree of height 5 (root at height 0) is
- A simple graph has degree sequence 4, 3, 3, 2, 2. How many edges does it have?
- A graph is bipartite if and only if
- The max-heap [90, 80, 70, 60, 50] stored in an array has the key 85 inserted with the standard sift-up. The resulting array is
- The minimum number of comparisons needed to find both the largest and second-largest of 16 distinct elements (tournament method) is
- Which data structure follows the Last-In-First-Out principle?