Sunday 28 June 2015

Linked List Data Structure in C Programming

An Array is a liner data structure where the elements are stored in the sequence block of memory. In order occupy adjacent space you need to allocate block of memory that it required before allotted it. It is not possible to change the allotted space of you want to add some more elements to an array. That is why array is called static data structure.

 A list is refers to a set of items organized sequentially. An array is a list. In an array, the sequentially organization is by index. The size of an array must be specified precisely at the beginning and it is not always possible in all applications.

A list can also be represented by making each item in the list part of a structure that also contains a link to the structure containing the next item. This type of list is called a Linked List. The Linked List is called Dynamic data structure where the amount of memory required  can be varied during its use.


In the above Linked List the "Info" field represent data stored in the Linked List and The "link" field represent a link to the next node as stated early it contain the adders of  next field it to be linked. The end of the linked list is identified by looking the link/addresses field contain "Null" value.

Each Structure of the list is called node and each node consists of   two fields. First field contains information and second field contains the address of next node or next element. In other words it establishes a link from first element ti next element in the list.

Example of Linked List:


                               The best real time example to identify the linked list is in the form of a " Train". In a train the sets allotted for passengers are like info fields and the links between the two bogies is nothing but link field. For example watch the below image




Definition of Linked List:


                                          A Linked List is an ordered collection of finite, homogeneous data elements called nodes where the liner order is maintained by means of links or pointers.

Depending  on the  requirements the pointers are maintained, and accordingly the linked list are classified into three major groups.

1. Single Linked List
2. Double Linked List
3. Circular Linked List

1. Single Linked List


                      The single linked list contains one link per node, which points to the nest node in the list. In a singly linked list, the first node is known as HEADER or START points to the next node and the last node is known as TAIL points to the NULL. A single linked list is also known as list.

            An example of a single linked list can be cited as train in which two successive compartments are connected one by one as shown above.





2. Double Linked List


           In this type of linked list each node holds two-pointer fields. In the single linked list, address of only next element is pointed. Unlike that, in doubly linked list address of next as well as preceding elements are linked with current node. As an example of doubly linked list is shown below

3. Circular Linked List


                        In a circular list the first and last elements are adjacent. This type of list has neither end nor starting the address of first node in the linked filed of last node as show below

  

0 comments :

Post a Comment

Note: only a member of this blog may post a comment.

Machine Learning

More

Advertisement

Java Tutorial

More

UGC NET CS TUTORIAL

MFCS
COA
PL-CG
DBMS
OPERATING SYSTEM
SOFTWARE ENG
DSA
TOC-CD
ARTIFICIAL INT

C Programming

More

Python Tutorial

More

Data Structures

More

computer Organization

More
Top