Skip to content

Commit

Permalink
Added algorithm.md in searches
Browse files Browse the repository at this point in the history
  • Loading branch information
paras-2407 committed Oct 10, 2023
1 parent f505667 commit a13f49a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions searches/algorithm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Algorithm of Searching
* Initialize an index variable to track the position where the value to search is found (set to an initial value, typically -1 to indicate not found).

* Start looking through the data, comparing each element with the value to search.

* If a match is found, update the index variable to the current position and stop searching.

* Continue searching until the end of the data or until a match is found.

* After the search, if the index remains at its initial value, it means the value to search was not found, so return a special value (e.g., -1) and taking this into consideration output an appropriate line for value not found. Otherwise, return the index where the search key was found.

0 comments on commit a13f49a

Please sign in to comment.