Linear search, also called sequential search, is a method for finding an element within a list by checking each element in sequence until a match is found or the whole list has been searched. It runs in linear time in the worst case, making at most n comparisons on a list of length n, and needs no precondition on how the list is ordered, unlike faster searches such as binary search that require a sorted list. This description is adapted from Wikipedia contributors under CC BY-SA 4.0; changes were made. https://creativecommons.org/licenses/by-sa/4.0/
Facts
Time ComplexityWorst-case O(n), best-case O(1), average O(n). 1 Sources
1. Wikipedia: Linear Search
Wikimedia FoundationLead sectionQuote, Lead section
A linear search runs in linear time in the worst case, and makes at most n comparisons, where n is the length of the list.
View the Source Reader Challenges (0)
No disputes yet. Spotted an error or a better source? Open the first one.
Sign in to dispute this or suggest a correction.