diff --git a/src/main/java/com/thealgorithms/searches/LinearSearch.java b/src/main/java/com/thealgorithms/searches/LinearSearch.java index 3f273e167f0a..919cb759a2fd 100644 --- a/src/main/java/com/thealgorithms/searches/LinearSearch.java +++ b/src/main/java/com/thealgorithms/searches/LinearSearch.java @@ -1,47 +1,37 @@ -/** - * Performs Linear Search on an array. - * - * Linear search checks each element one by one until the target is found - * or the array ends. - * - * Example: - * Input: [2, 4, 6, 8], target = 6 - * Output: Index = 2 - * - * Time Complexity: O(n) - * Space Complexity: O(1) - */ package com.thealgorithms.searches; import com.thealgorithms.devutils.searches.SearchAlgorithm; /** - * Linear Search is a simple searching algorithm that checks - * each element of the array sequentially until the target - * value is found or the array ends. + * Linear Search is a simple searching algorithm that checks each element + * of the array sequentially until the target value is found or the array ends. * - * It works for both sorted and unsorted arrays. + *

It works for both sorted and unsorted arrays.

* - * Time Complexity: - * - Best case: O(1) - * - Average case: O(n) - * - Worst case: O(n) + *

Time Complexity: + *

+ *

* - * Space Complexity: O(1) + *

Space Complexity: O(1)

* * @author Varun Upadhyay * @author Podshivalov Nikita + * @author Yawar Ali * @see BinarySearch * @see SearchAlgorithm */ public class LinearSearch implements SearchAlgorithm { /** - * Generic Linear search method + * Generic Linear search method. * - * @param array List to be searched - * @param value Key being searched for - * @return Location of the key, -1 if array is null or empty, or key not found + * @param array List to be searched. + * @param value Key being searched for. + * @return Location of the key, -1 if array is null or empty, or key not found. */ @Override public > int find(T[] array, T value) {