Write an algorithm and draw a corresponding flowchart to search a number in the given list of numbers and also display its position. 10m Dec2005
An algorithm is a finite set of steps defining the solution of a particular problem. An algorithm is expressed in pseudo code – something resembling C language or Pascal, but with some statements in English rather than within the programming language
- A sequential solution of any program that written in human language, called algorithm.
- Algorithm is first step of the solution process, after the analysis of problem, programmers write the algorithm of that problem.
Pseudo code:
- Input a Key
- Initialize Index to zero
- While Index is less than SizeofArray
- If Array[Index] equal to Key
- Print Key Found at Location
- Skip Loop
- Increment Index
- If Index equal to SizeofArray
- Print Key Not Found
Detailed Algorithm:
Step 1: Input Key
Step 2: Index = 0
Step 3: While (Index < SizeofArray)
If (Array[Index] == Key)
Print Key Found at Location
goto Step 6
Index++
Step 4: If (Index == SizeofArray)
Step 5: Print Key Not Found
Step 6: End
Flowchart:-