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

February 22, 2014 0 Comments


               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:

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

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.

Jackrin Reacher

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google