Search an element in linked list

Search an element in linked list

In this topic we will discuss about how to insearch element in singly linked list. we know that  In singly linked list,we have two arrays in linked list first one is link and second is info link is used for hold the address or pointer to the next link and info have stored the data.

When we are searching the element then that element will be represented by Item variable. The Item variable will be compared all the element until traversal will not be finished,pointer will help the traverse to the linked list (ptr).

In the searching have two ways, when the list is unsorted and list is sorted then how will we search the element.

  • When the list is unsorted, we will  start small element  in the linked list  then  compared the info field to the item [Item=(Info{ptr})],If the Item is equal to info pointer then print the location where as element [LOC=PTR] then Exit.


       PTR=LINK(PTR) to move the next pointer until the pointer will be null.