Question 19

Consider the following two C++ statements and the accompanying contexts.

Consider the following two C++ statements and the accompanying contexts. (A) return P→next = = NULL; // P is a pointer to an element in the link list L. (B) return S → next == NULL; // S is a stack implemented as a link list. If the return value is TRUE in both cases, which of the following is correct ?
  1. AP points to the last element in L and S is empty.
  2. BP points to the last element in L and S is full.
  3. CL is empty and S is full.
  4. DBoth L and S are empty.
Show answerHide answer

Correct answer: (B) P points to the last element in L and S is full.

Explanation

Answer as per the book's key (b). Note that S→next == NULL would normally mean the stack is empty, so this question is doubtful.

From DSSSB TGT Computer Science Practice Set 1

This is question 19 of DSSSB TGT Computer Science Practice Set 1. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.