Title: Programs based on linked list.

Introduction:

 The linked allocation method of storage is more suitable for much computer application. It can
result in both the efficient use of computer storage and computer time. It has following
characteristics:

   1. Unpredictable storage requirement
   2. Extensive manipulation of data stored

   Linked List: A linked list or one way list or chain list is a linear collection of data elements
   called node where the linear order is given by means of pointer. Each node is divided into
   two parts:

   1. Information of the elements.
   2. Address of the next node in the list called as linked field or next pointer field. The
      pointer of the last node contains a special value called null pointer which is an invalid
      address. In actual practice, 0 or negative number is used for null pointer.

       Important concepts related to Linked List:

       Node: Each item in the list is called a node and contains two fields such as:
              1. Information field
              2. Next address field

       1. Information field: The Information field holds the actual elements on the list.

       2. Next address field: The Next address field contains the address of the next node in
       the list.

       Pointer and Null pointer: The address which is used to access a particular node is known
       as a pointer. The entire linked list is accessed from an external pointer list that points to
       the first node in the list. The next address of the last node in the list contains a special
       value, known as null, which is not valid address. This null pointer is used to signal the
       end of the list.

       Empty list: The list with no nodes on it is called empty list or null list. The value of the
       external pointer list to such a list is the null pointer. A list can be initialize to the empty
       list by the operation list=null.
Operations on linked list:

       1. Searching
       2. Insertion
       3. Deletion

       1. Searching for node from linked list
          Algorithm: Search_node(Start, Data)
          [Searches for data, start ptr to first node]
          Step 1: Start
          Step 2: Accept linked list and data
          Step 3: Set temp=Start
          Step 4: While link [temp] not equal to Null [check till end]
                   If info [temp] =Data, then
                 Write: “Found Successfully”
                    Exit [if found, stop]
                 [End of if]
                  Set Temp=Link [tamp] [pointer is incremented to next]
                  [End of while]
          Step 5: Write: “Not Found”
          Step 6: Exit [stop]




Types of linked list:

1. Linear

2. Doubly

3. Circular

1. Linear linked list

 Contained within itself the address of the next items such an explicit ordering gives rise to a data
structure, which is known as a linear linked list.
info          Next             Node




2. Doubly linked list

In a doubly linked list, each node contains, besides the next-node link, a second link field
pointing to the previous node in the sequence. The two links may be called forward(s) and
backwards, or next and previous.

   Head                           address to next node             last




                        Address to previous node

3. Circular

Circular list

In a circularly linked list, all nodes are linked in a continuous circle, without using null. For lists
with a front and a back (such as a queue), one stores a reference to the last node in the list. The
next node after the last node is the first node. Elements can be added to the back of the list and
removed from the front in constant time.

Circularly linked lists can be either singly or doubly linked.

Both types of circularly linked lists benefit from the ability to traverse the full list beginning at
any given node. This often allows us to avoid storing firstNode and lastNode, although if the list
may be empty we need a special representation for the empty list, such as a lastNode variable
which points to some node in the list or is null if it's empty; we use such a lastNode here. This
representation significantly simplifies adding and removing nodes with a non-empty list, but
empty lists are then a special case.



                First node                                  last node
Advantages of linked list :

1. Linked list is an example of dynamic data structure

2. Linked list can be grow and shrink during execution of the program

3. It allows to use memory efficiently the memory is not allocated in advance so according to
need,memory can be allocated

4. Representation of the linear data structure can be easily implement using it.

5. Memory is freed whenever there is no need of it.

6. Insertion and deletion are efficient and easy.

Link list assi

  • 1.
    Title: Programs basedon linked list. Introduction: The linked allocation method of storage is more suitable for much computer application. It can result in both the efficient use of computer storage and computer time. It has following characteristics: 1. Unpredictable storage requirement 2. Extensive manipulation of data stored Linked List: A linked list or one way list or chain list is a linear collection of data elements called node where the linear order is given by means of pointer. Each node is divided into two parts: 1. Information of the elements. 2. Address of the next node in the list called as linked field or next pointer field. The pointer of the last node contains a special value called null pointer which is an invalid address. In actual practice, 0 or negative number is used for null pointer. Important concepts related to Linked List: Node: Each item in the list is called a node and contains two fields such as: 1. Information field 2. Next address field 1. Information field: The Information field holds the actual elements on the list. 2. Next address field: The Next address field contains the address of the next node in the list. Pointer and Null pointer: The address which is used to access a particular node is known as a pointer. The entire linked list is accessed from an external pointer list that points to the first node in the list. The next address of the last node in the list contains a special value, known as null, which is not valid address. This null pointer is used to signal the end of the list. Empty list: The list with no nodes on it is called empty list or null list. The value of the external pointer list to such a list is the null pointer. A list can be initialize to the empty list by the operation list=null.
  • 2.
    Operations on linkedlist: 1. Searching 2. Insertion 3. Deletion 1. Searching for node from linked list Algorithm: Search_node(Start, Data) [Searches for data, start ptr to first node] Step 1: Start Step 2: Accept linked list and data Step 3: Set temp=Start Step 4: While link [temp] not equal to Null [check till end] If info [temp] =Data, then Write: “Found Successfully” Exit [if found, stop] [End of if] Set Temp=Link [tamp] [pointer is incremented to next] [End of while] Step 5: Write: “Not Found” Step 6: Exit [stop] Types of linked list: 1. Linear 2. Doubly 3. Circular 1. Linear linked list Contained within itself the address of the next items such an explicit ordering gives rise to a data structure, which is known as a linear linked list.
  • 3.
    info Next Node 2. Doubly linked list In a doubly linked list, each node contains, besides the next-node link, a second link field pointing to the previous node in the sequence. The two links may be called forward(s) and backwards, or next and previous. Head address to next node last Address to previous node 3. Circular Circular list In a circularly linked list, all nodes are linked in a continuous circle, without using null. For lists with a front and a back (such as a queue), one stores a reference to the last node in the list. The next node after the last node is the first node. Elements can be added to the back of the list and removed from the front in constant time. Circularly linked lists can be either singly or doubly linked. Both types of circularly linked lists benefit from the ability to traverse the full list beginning at any given node. This often allows us to avoid storing firstNode and lastNode, although if the list may be empty we need a special representation for the empty list, such as a lastNode variable which points to some node in the list or is null if it's empty; we use such a lastNode here. This representation significantly simplifies adding and removing nodes with a non-empty list, but empty lists are then a special case. First node last node
  • 4.
    Advantages of linkedlist : 1. Linked list is an example of dynamic data structure 2. Linked list can be grow and shrink during execution of the program 3. It allows to use memory efficiently the memory is not allocated in advance so according to need,memory can be allocated 4. Representation of the linear data structure can be easily implement using it. 5. Memory is freed whenever there is no need of it. 6. Insertion and deletion are efficient and easy.