(Docs)Updated Linear-Search.md

I noticed the steps in the algorithm to be continuous which would make it inconvenient for the reader. So, I reformatted the steps to look much cleaner and readable.
pull/1096/head
Nishanth Chandra 2022-12-07 21:18:06 +05:30 committed by GitHub
parent e60d299077
commit aba1357a9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 7 deletions

View File

@ -11,12 +11,19 @@ Linear search is usually very **simple to implement**.
**Linear Search( Array A, Value x)** **Linear Search( Array A, Value x)**
Step 1: Set i to 1 Step 1: Set i to 1
Step 2: if i > n then go to step 7 Step 2: if i > n then go to step 7
Step 3: if A[i] = x then go to step 6 Step 3: if A[i] = x then go to step 6
Step 4: Set i to i + 1 Step 4: Set i to i + 1
Step 5: Go to Step 2 Step 5: Go to Step 2
Step 6: Print Element x Found at index i and go to step 8 Step 6: Print Element x Found at index i and go to step 8
Step 7: Print element not found Step 7: Print element not found
Step 8: Exit Step 8: Exit
## Pseudocode ## Pseudocode