Friday, March 1, 2019

IMPLEMENTATION OF LIST ADT

Implementation of list ADT

  1. Array implementation
  2. Linked list implementation


1.Array implementation  


  • Array is a collection of specific number of data store in a consecutive memory location.
  • The very common linear structure is array.
  • An array is a list of finite number 'n' of homogeneous data elements such that,
              (a).The elements of the array are referenced respectively                        by an index consisting of 'n' consecutive numbers.
               (b).The elements of the array are stored respectively in                           successive memory location.

                      

      A  normal variable:

                           
                       int b;
         place a value into 'b' with the statement b=6.
                          

      A  array variable:

               
                       int a[4];
           Place a value into 'a' with the statement a[2]=6.
                               
  • Insertion and deletion operation are expensive as it requires more data movements.                                                                
  • Find and print list  operation takes constant time.
  • The worst case of these operation is O(N).                                                              

2.Linked list implementation:

                
            linked list consists of series of nodes. Each  node contains the element and a pointer to successor node.the pointer of the last node points to null.
                  
                                          
              Insertion and deletion operation are easily perform using linked list.

                                         ******* 
                                               
                                        
                   

No comments:

Post a Comment