The following steps in a linked list p = getnode() info (p) = 10 next (p) =…

2013

The following steps in a linked list

p = getnode()
 info (p) = 10
 next (p) = list
 list = p

result in which type of operation?

  1. A.

    pop operation in stack

  2. B.

    removal of a node

  3. C.

    inserting a node at beginning 

  4. D.

    modifying an existing node

Attempted by 406 students.

Show answer & explanation

Correct answer: C

The code snippet performs the following steps: 1. A new node p is allocated (p = getnode()). 2. Data is assigned to the node (info(p) = 10). 3. The new node's next pointer is set to the current list head (next(p) = list). 4. The list head pointer is updated to point to the new node (list = p). This sequence represents inserting a new element at the beginning of the linked list.

Explore the full course: Isro