A sequential or linear search algorithm is a very simple method to find a particular element in an array. It is considered to be the simplest search algorithm. The implementation of this algorithm does not require the use of ordered elements (sorted arrays). It relies on brute force strategy to accomplish its purpose.
Run this program in Mat's pseodocode software tool and change the search values.
Convert the above program into a python program using codeskulptor3.
Runestone academy - Sequential search - Read through and complete the two self-check questions
Extra tutorials
Linear (Sequential) search explained- bradfieldcs
Linear Search Tutorial - The national academy (Great tutorial - you can skip through parts but try the questions at the end)
Computer Scientists like to talk about the efficiency of an algorithm in terms of its best, average, and worst case. The best case occurs when the data is organised in such a way that the algorithm works at its peak performance or fastest. The average case occurs when the data is organised in such a way that the algorithm works at its average speed. The worst case occurs when the algorithm is least efficient or works at its slowest speed.
The worst case is often the one most people look at when analysing an algorithm because it gives you the best guaranteed performance of the algorithm. The average case, although of interest, is sometimes hard to estimate.
Assume n represents the size of a list to be searched.
The Linear Search has the following time efficiency:
Best Case: When the item to be searched is the first item in the list.
Worst Case: When the item to be searched is at the end of the list or not in the list. The search makes n comparisons before it determines that the item is not in the list.
Average Case: When the item to be searched is in a random location. The search makes on average n/2 comparisons before it locates the item.