C LANGUAGE UNIT III

Searching  

 Linear search: The simple approach of doing the linear search is :

1. It starts to search from zeroth index of the array.
2. If the element found the index get stored nad the loop terminated prematurely using the break statement.
3. if the flag has the value 0 then element not found or 1 then element found in the gien array.

linear search is rarely used as the other search algorithms like binary search or hash tables easily searches the element efficiently


No comments:

Post a Comment