Skip over navigation

Linear Search

Introduction and Summary

Table of Contents

Terms

The sequential search, also known as the linear search, are the most basic search algorithms and are often the first search method learned in introductory computer science courses.

The basic strategy is straightforward. Every element in the data set is examined in the order presented until the value being searched for is found. If the value being searched for doesn't exist, a flag value is returned (such as -1 for an array or NULL for a linked list).

Sequential search is at best O(1) , at worst O(n) , and on average O(n) . If the data being searched are not sorted, then it is a relatively efficient search. However, if the data being searched are sorted, we can do much better.

Follow Us