{"id":6729,"date":"2021-09-30T15:30:32","date_gmt":"2021-09-30T10:00:32","guid":{"rendered":"https:\/\/python-programs.com\/?p=6729"},"modified":"2021-11-22T18:39:29","modified_gmt":"2021-11-22T13:09:29","slug":"linear-search-in-python","status":"publish","type":"post","link":"https:\/\/python-programs.com\/linear-search-in-python\/","title":{"rendered":"Linear Search in Python"},"content":{"rendered":"

Don’t stop learning now. Get hold of all the important Java fundamentals with the Simple java program example<\/a> guide and practice well.<\/p>\n

Linear Search works in much the same way as we search for a random list of objects.<\/p>\n

If we need to find a word on a specific page, we will begin at the top and go through each word one by one before we find the word we are searching for.<\/p>\n

Linear Search:<\/strong><\/p>\n

Linear search is a method for locating elements in a sequence. It’s also known as a sequential scan. It is the most basic searching algorithm since it searches for the desired element sequentially.<\/p>\n

It compares each element to the value that we are looking for. If both match, the element is found, and the algorithm returns the index position of the key.<\/p>\n

Examples:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

given_elements =[2, 7, 3, 4, 9, 15]\u00a0 \u00a0key= 9<\/pre>\n

Output:<\/strong><\/p>\n

Element 9 is found at index 4<\/pre>\n

Linear Search in Python<\/h2>\n