1.

Example of linear search in Data stucture

Answer»

re's it :Linear SEARCH is a very simple search ALGORITHM. In this type of search, a sequential search is made over all items one by one. Every item is checked and if a match is found then that particular item is RETURNED, otherwise the search continues till the end of the data collection.AlgorithmLinear Search ( ARRAY a[ ], Value x)Step 1: Set i to 1Step 2: if (i > n) then go to step 7Step 3: if (a[i] = x) then go to step 6Step 4: Set i to i + 1Step 5: Go to Step 2Step 6: Print Element x Found at index i and go to step 8Step 7: Print element not foundStep 8: Exit



Discussion

No Comment Found