From 23aa9082fc62b14adb7aecfa2ca3b2774f0f4642 Mon Sep 17 00:00:00 2001 From: jiya <122276932+jiya10208@users.noreply.github.com> Date: Sat, 12 Oct 2024 13:01:22 +0530 Subject: [PATCH] Update linear_search.cpp Description of linear search algo Time complexity space complexity --- search/linear_search.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/search/linear_search.cpp b/search/linear_search.cpp index 82cd4b4ce18..7653f60b1c2 100644 --- a/search/linear_search.cpp +++ b/search/linear_search.cpp @@ -1,7 +1,18 @@ /** * \file - * \brief [Linear search - * algorithm](https://en.wikipedia.org/wiki/Linear_search) + * \brief [Linear search algorithm] + * Linear search algorithm is based on traversing the the list element one by one, until you find your target element. + * It is also known as sequential search. + +Time complexity: O(n) + * Worst case: O(n) (Worst case will be : the last element is the target element) + * Best Case: O(1) (The best case will be: the first element is the target element ) + +Space complexity: O(1) + * Worst case: O(1) + * Best Case: O(1) + + * (https://en.wikipedia.org/wiki/Linear_search) * * @author Unknown author * @author [Ritika Mukherjee](https://github.com/ritikaa17)