Question 21

Computer Awareness Linked Lists Hard

If we want to find last node of a singly linked list then the correct coding is

(A) if (temp \( \rightarrow \) link! = NULL) temp = temp \( \rightarrow \) link
(B) if (temp \( \rightarrow \) data \( == \) Num \( ) \) temp \( = \) temp \( \rightarrow \) link
(C) While (temp \( \rightarrow \) link! = NULL) temp \( = \) temp \( \rightarrow \) link
(D) While (temp \( \rightarrow \) link! = data) temp \( = \) temp \( \rightarrow \) link
✓ Correct Answer: Option C Verified Solution

📘 Step-by-Step Solution & Detailed Explanation:

To reach the last node, we have to keep moving forward as long as the current node has a next node. That needs a loop, not a single if:

while (temp->link != NULL)
    temp = temp->link;

When the loop stops, temp->link is NULL, so temp points to the last node.

Option (A) uses if, so it moves only one step. Options (B) and (D) check the data field, which is unrelated.

Answer: (C)

Practice Similar Linked Lists Questions

Reinforce your conceptual grasp with related questions from CUET-MCA 2024:

Q8 Each node is having a successor node in \( \) :
Solve →
Q1 Which one of the following data structures are preferred in database...
Solve →
Q5 \[ |l l| List - I & List - II \\ (A) Asynchronous & (II) The operation is...
Solve →
Q6 Consider a system with 1 K pages and 512 frames and each page is of size 2...
Solve →
Q9 How does the number of page frames affect and number of page faults for a...
Solve →
Full-Length Test Series

Prepare for CUET-MCA Under Real Exam Conditions

Take timed full-length mock tests with authentic question distributions, negative marking (+12/-3 in Math), and instant All India Rank calculation.

Start Free Mock Test Series →