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?
- A.
pop operation in stack
- B.
removal of a node
- C.
inserting a node at beginning
- 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.