Linear Search


Introduction and Summary

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.

Take a Study Break

Green YOUR SCHOOL!

Click here to get involved with dosomething.org!

John Krasinski's BIG MIRACLE

Click to watch the trailer and read exclusive star interviews!

Do you like Anna?

Read Dear Albert... from ANNA's perspective!

BATTLESHIP, the movie

Here's why we're super jazzed about it.

Do energy juices actually work?

Our blogger puts 'em to the test!


The Book

Cover image

Read What You Love, Anywhere You Like

Get Our FREE NOOK Reading Apps