Linked List Representation in C

In C, a linked list is represented using a node structure and one or more pointers (usually head, sometimes tail). This design gives dynamic memory usage and easy pointer-based linking between nodes.

1) Node structure in C

Diagram: singly linked list node in C with data field and next pointer
Singly linked list — node fields data and next.
struct Node {
    int data;
    struct Node *next;
};

struct Node *head = NULL;   // empty list
struct Node *tail = NULL;   // optional, for faster end insert
  • data stores the value for the node.
  • next stores the address of the next node.
  • head points to the first node; when list is empty, head == NULL.

2) What is UDD? (User-Defined Data type)

In C, a User-Defined Data type (UDD) is a type you create, instead of using only built-in types like int, char, or float. struct Node is a UDD because we define its fields ourselves.

typedef struct Node {
    int data;
    struct Node *next;
} Node;

Node *head = NULL;

Using UDD makes linked-list code cleaner and reusable: every function can work with the same logical node type.

3) What is a self-referential structure?

A self-referential structure is a structure that contains a pointer to the same structure type. In linked lists, this is the key idea that creates a chain of nodes.

  • struct Node *next; means each node can point to another Node.
  • Without this self-reference, nodes cannot be linked dynamically.
  • This pattern is also used in trees and graph node representations.

4) Why is structure used for linked list?

  • Group related fields: data and link(s) stay together as one node record.
  • Dynamic memory-friendly: each node is allocated when needed using malloc().
  • Flexible node design: you can add more fields (e.g., id, name, marks, timestamp) without changing list logic.
  • Pointer-based linking: structures can safely hold pointer members like next and prev.
  • Readable code: operations like insert/delete/traverse become clear via node->next style access.