Linked List

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Linked List:A linked list is the chain of nodes or date items connected by pointers and each node contains

a pointer pointing to the address of next node or data item. A linked list is an ordered list of data items. A link list is a collection of records of the same data type, and all such records are connected through pointers each record in a linked list has a pointer field pointing to the next record in the list. The pointer field in the last record of the list is assigned the null value. A pointer variable is used to point to the first record in the list.

Advantages of linked list: It is not necessary to know in advance the number of elements to be stored in the list and therefore, need not allocate. d as and when necessary. In a linked list, insertions and deletions can be handled efficiently without fixing the size of the memory in advance. An important advantage of linked lists over arrays is that the linked list uses exactly as much memory as it needs, and can be made to expand to fill all available memory locations if needed. Disadvantages: The traversal is sequential. Increased overhead for storing pointers for linking the data items.

Type of Linked List:There are three types of linked list: Singly linked list Doubly linked list Circular linked list Singly linked list:- In This type of linked list, each node contains two fields i.e. data and a link pointing to the next node in the list.

The first node in the list is pointed by a start pointer. The node in the list has a link pointer field containing a Null. Doubly Linked List:-In this type of linked list, each node contains and two links, one link pointing to the previous node and one link pointing to the next node. Doubly linked list can be traversed forward as well as well as backward.

Circular Linked List: Circular linked list are the linked lists which are obtained by linking the last node of the linked list to the first node of the list. In circular linked list, the last node does not contain the NULL pointer. Instead it contains the pointer of the first node.

You might also like