Linked List

Bodhak linked list using c Tutorial in this chapter we will discuss Linked List of Data Structures. All the topics are explained with the examples.

It defined as a collection of self – referential structures ordered not by their physical placement in memory but by logical links that are stored as part of the data in the structure itself.


Linked List

Each structure of the list is called a node.

Each node consists of the data and a pointer pointing to the next node on the list.

Accessed via a pointer to the first node of the list subsequent nodes are accessed via the link-pointer member of the current node Link pointer in the last node is set to null to mark the list’s end.

It permits insertion and removal of nodes at any point in the list in constant time, but do not allow random access.

Use a linked list instead of an array when you have an unpredictable number of data elements your list needs to be sorted quickly.

linked list using c

Singly linked list:

Begins with a pointer to the first node terminates with a null pointer Only traversed in one direction Circular, singly linked

Circular, singly linked: Pointer in the last node points back to the first node

Doubly linked list: Two “start pointers” – first element and last element Each node has a forward pointer and a backward pointer Allows traversals both forwards and backward

Circular, doubly linked list: backward forward pointer of the last node points to the first backward pointer of the first node points to the last node

Next Page