diff --git a/search/linear_search.cpp b/search/linear_search.cpp index 8849549e5..142506951 100644 --- a/search/linear_search.cpp +++ b/search/linear_search.cpp @@ -1,5 +1,18 @@ +/** + * \file + * \brief [Linear search + * algorithm](https://en.wikipedia.org/wiki/Linear_search) + */ #include +/** + * Algorithm implementation + * \param [in] array array to search in + * \param [in] size length of array + * \param [in] key key value to search for + * \returns index where the key-value occurs in the array + * \returns -1 if key-value not found + */ int LinearSearch(int *array, int size, int key) { for (int i = 0; i < size; ++i) { if (array[i] == key) { @@ -10,6 +23,7 @@ int LinearSearch(int *array, int size, int key) { return -1; } +/** main function */ int main() { int size; std::cout << "\nEnter the size of the Array : ";