In the standard linked-list representation of a stack, where TOP points to the…

2017

In the standard linked-list representation of a stack, where TOP points to the first node and links continue toward older stack elements, the null pointer of the last node in the list represents:

  1. A.

    Beginning of the stack

  2. B.

    Bottom of the stack

  3. C.

    Middle of the stack

  4. D.

    In between some value

Attempted by 104 students.

Show answer & explanation

Correct answer: B

Correct answer: Bottom of the stack.

  • Standard assumption: In a linked stack, insertion and deletion are normally performed at the TOP/front node so push and pop remain O(1).

  • Link direction: Each node points to the next older element in the stack.

  • Null pointer: The last node has no older element below it, so its link is NULL. That NULL link marks the bottom of the stack, not the top.

Explore the full course: Coding For Placement