Skip to content

Commit 23aa908

Browse files
authored
Update linear_search.cpp
Description of linear search algo Time complexity space complexity
1 parent 136e6c0 commit 23aa908

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

search/linear_search.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
/**
22
* \file
3-
* \brief [Linear search
4-
* algorithm](https://en.wikipedia.org/wiki/Linear_search)
3+
* \brief [Linear search algorithm]
4+
* Linear search algorithm is based on traversing the the list element one by one, until you find your target element.
5+
* It is also known as sequential search.
6+
7+
Time complexity: O(n)
8+
* Worst case: O(n) (Worst case will be : the last element is the target element)
9+
* Best Case: O(1) (The best case will be: the first element is the target element )
10+
11+
Space complexity: O(1)
12+
* Worst case: O(1)
13+
* Best Case: O(1)
14+
15+
* (https://en.wikipedia.org/wiki/Linear_search)
516
*
617
* @author Unknown author
718
* @author [Ritika Mukherjee](https://github.com/ritikaa17)

0 commit comments

Comments
 (0)