DS - Searching a Linked List
Searching a Linked List
Seaarching in a linked list is very basic data structure operation.
Here in a linked list, it is little time consuming task, as like linear search in array.
Here in linked list we have to compair the elememnt with each & every element of linked list.
From the below algorithm we will try to understand how search operation takes place in linked list.
Algorithm for searching a linked list.
As we can see in above algorithm the searching operation is expalined in easy manner in step by step pattern.
In the first step ptr is started from starting location of linked list, then while loop will go through all the elements of linked list till null pointer.
Now we have to compair item with each and every element of INFO linked list.
If element founds the searc operation becomes successfull otherwise unsuccessfull.
However counter must goes continuously with the help of link ptr.
Comments
Post a Comment