Algorithm and flowchart to Search a particular data from the given Array of numbers using: Linear Search Method.
Algorithm: Linear Search
Goal: Find whether a given element (key) is present in an array and, if so, return its position.
Steps:
Start
Input n (number of elements in the array).
Input the array arr[0…n-1].
Input key (element to be searched).
Set i = 0.
Repeat whilei < n:
If arr[i] == key:
Print “Element found at position i” (or index i+1 if using 1-based position).
Stop.
Else: Increment i by 1.
If loop ends without finding the element: Print “Element not found”.
Stop.
Flowchart: Linear Search

Post Comment