searches.linear_search ====================== .. py:module:: searches.linear_search .. autoapi-nested-parse:: This is pure Python implementation of linear search algorithm For doctests run following command: python3 -m doctest -v linear_search.py For manual testing run: python3 linear_search.py Attributes ---------- .. autoapisummary:: searches.linear_search.user_input Functions --------- .. autoapisummary:: searches.linear_search.linear_search searches.linear_search.rec_linear_search Module Contents --------------- .. py:function:: linear_search(sequence: list, target: int) -> int A pure Python implementation of a linear search algorithm :param sequence: a collection with comparable items (as sorted items not required in Linear Search) :param target: item value to search :return: index of found item or -1 if item is not found Examples: >>> linear_search([0, 5, 7, 10, 15], 0) 0 >>> linear_search([0, 5, 7, 10, 15], 15) 4 >>> linear_search([0, 5, 7, 10, 15], 5) 1 >>> linear_search([0, 5, 7, 10, 15], 6) -1 .. py:function:: rec_linear_search(sequence: list, low: int, high: int, target: int) -> int A pure Python implementation of a recursive linear search algorithm :param sequence: a collection with comparable items (as sorted items not required in Linear Search) :param low: Lower bound of the array :param high: Higher bound of the array :param target: The element to be found :return: Index of the key or -1 if key not found Examples: >>> rec_linear_search([0, 30, 500, 100, 700], 0, 4, 0) 0 >>> rec_linear_search([0, 30, 500, 100, 700], 0, 4, 700) 4 >>> rec_linear_search([0, 30, 500, 100, 700], 0, 4, 30) 1 >>> rec_linear_search([0, 30, 500, 100, 700], 0, 4, -6) -1 .. py:data:: user_input