OA. free
Free
Qualcomm Embedded Systems & Hardware Embedded Systems & Hardware Medium

Question 39 Which type of linked list does the below given code snippet represent?

Qualcomm technical mcq question, verified with a worked answer. Free to practise - no sign-up.

Question 39

Which type of linked list does the below given code snippet represent?

struct node {
    int data;
    struct node *next;
    struct node *prev;
}
Choose one option.
Show answer & explanation
Answer: A. Doubly linked list

The struct defines a node with three components: data, a next pointer, and a prev pointer. The presence of both next and prev pointers is the defining characteristic of a doubly linked list, which allows traversal in both directions. The struct itself does not enforce circularity (where the last node points back to the first); circularity is a property of how nodes are linked at runtime, not the struct definition.

Step-by-step Derivation:
Analysis of the node structure:

  1. The struct contains: int data, struct node *next, struct node *prev
  2. A single forward pointer (next) defines a singly linked list
  3. A single backward pointer (prev) alone would be unusual
  4. Both next AND prev pointers together define a doubly linked list — each node can reference both its successor and predecessor
  5. Circular vs. non-circular is determined by runtime linking logic (e.g., whether last.next points to first and first.prev points to last), not by the struct definition
  6. The struct as written is the template for a doubly linked list node, regardless of whether instances are arranged circularly