File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed
src/main/java/com/thealgorithms/searches Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change 11package com .thealgorithms .searches ;
22
33import 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+
1924public class LinearSearch implements SearchAlgorithm {
2025
2126 /**
You can’t perform that action at this time.
0 commit comments