Skip to content

Commit 782d075

Browse files
authored
Improve documentation for Linear Search algorithm (#7214)
1 parent fd0bcb7 commit 782d075

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/main/java/com/thealgorithms/searches/LinearSearch.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
package com.thealgorithms.searches;
22

33
import com.thealgorithms.devutils.searches.SearchAlgorithm;
4-
54
/**
6-
* Linear search is the easiest search algorithm It works with sorted and
7-
* unsorted arrays (an binary search works only with sorted array) This
8-
* algorithm just compares all elements of an array to find a value
5+
* Linear Search is a simple searching algorithm that checks
6+
* each element of the array sequentially until the target
7+
* value is found or the array ends.
8+
*
9+
* It works for both sorted and unsorted arrays.
910
*
10-
* <p>
11-
* Worst-case performance O(n) Best-case performance O(1) Average performance
12-
* O(n) Worst-case space complexity
11+
* Time Complexity:
12+
* - Best case: O(1)
13+
* - Average case: O(n)
14+
* - Worst case: O(n)
1315
*
14-
* @author Varun Upadhyay (https://github.com/varunu28)
15-
* @author Podshivalov Nikita (https://github.com/nikitap492)
16+
* Space Complexity: O(1)
17+
*
18+
* @author Varun Upadhyay
19+
* @author Podshivalov Nikita
1620
* @see BinarySearch
1721
* @see SearchAlgorithm
1822
*/
23+
1924
public class LinearSearch implements SearchAlgorithm {
2025

2126
/**

0 commit comments

Comments
 (0)