0% found this document useful (0 votes)
420 views

What Is A Sequential Search and What Is An Example of One?

A sequential search, also called a linear search, examines elements in a list one-by-one in the order they appear until finding a match. It is used when a list is unordered. The search begins at the first element and proceeds sequentially to subsequent elements until the target is found or all elements are examined. An example searches a list of numbers to find the target "4", starting at the first element and checking each following element until reaching the "4". The maximum and average number of searches required depends on the number of list elements.

Uploaded by

kingraaja
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
420 views

What Is A Sequential Search and What Is An Example of One?

A sequential search, also called a linear search, examines elements in a list one-by-one in the order they appear until finding a match. It is used when a list is unordered. The search begins at the first element and proceeds sequentially to subsequent elements until the target is found or all elements are examined. An example searches a list of numbers to find the target "4", starting at the first element and checking each following element until reaching the "4". The maximum and average number of searches required depends on the number of list elements.

Uploaded by

kingraaja
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

What is a sequential search and what

is an example of one?

The sequential search (sometimes called a linear search) is the simplest type of search, it is
used when a list of integers is not in any order. It examines the first element in the list and then
examines each "sequential" element in the list until a match is found. This match could be a
desired work that you are searching for, or the minimum number in the list.
It is important to remember that the:
- maximum number of searches required is: n+1
- average number of searches required is: (n+1)/2
(n = the number of elements on the list)
Sequential Search Example:
We start by searching for the target at the first element in the list and then proceed to examine
each element in the order in which they appear.
Suppose we are looking for the character "4." (keep in mind this is a simple diagram to help you
understand the basics)

Target? No.

Target? No.

Target? YES! (end search)

Target? No.

Target? No.

Once the target item has been found, a Boolean true, or the index where it
was found, is returned.
A couple of good references can be found at:
http://www.sparknotes.com/cs/searching/linearsearch/section1.html
http://www.lcusd.net/lchs/dclausen/apcs_cpp/PowerPoint/sequentialsearchch8vectors/sld002.h
tm
http://www.cse.ucsc.edu/classes/cmps012b/Spring97/Lecture11/sld009.htm
Now some questions:
1) A sequential search is also referred to as a:
a) binary search
b) static search
c) linear search
d) algorithm search
(ANSWER: C)
2) In a sequential search the elements are reviewed:

a) all at once
b) a few at a time
c) randomly
d) one at a time
(ANSWER: D)
3) When will a sequential search end?
(ANSWER: When the desired value is found, OR when the end of the array is reached)
4) Where does the sequential search begin its search for the target integer?
(ANSWER: The sequential search begins at the first element of the list and continues until it
reaches the target integer.)

You might also like