-->

Saturday, February 22, 2014

Searching In Circular linked list for Data Structure in 'C'

Searching In Circular linked list for Data Structure in 'C'

Searching:

               In order to do searching in circular linked list, get the information to be searched and set PTR with ROOT. Compare Information with INFO of PTR, if it is equal ‘search is successful’ and terminate operation otherwise update PTR with LINK of PTR and repeat the process. Continue the operation till the end. The end is recognized by an address of first node given by ROOT stored in Link of PTR.

Algorithm for searching:

       SEARCHCLL(ROOT, IN)
       [ROOT is starting address of Linked List and
         IN is Information to search in Linked List]
        PTR<--ROOT
        If PTR = NULL Then:
         Write: ‘Empty Circular linked list’
         Exit.
        [End of If]
        Repeat While IN< >PTR-->INFO
         If PTR-->LINK = ROOT Then:
            Break
         [End of If]
         PTR<--PTR-->LINK
         [End of while]
         If PTR-->INFO = IN Then:
           Write: ‘Search Successful’
         Else:
          Write: ‘Search Unsuccessful’
         [End of If]
         Exit.

The insertion and deletion operations in circular linked list are similar to that of linear linked list and they are left as exercise. The hint is to only replace the end node checking condition of the linear linked list with that of circular linked list. This condition replacement you have learned in traversing and searching in circular linked list.

Read other related articles

Also read other articles

© Copyright 2013 Computer Programming | All Right Reserved