Chapter 9 Searching
Chapter 9 Searching
Algorithm
Chapter 9: Searching
Search
Linear search is also known as sequential search.
Linear search or sequential search is a method for
finding an element within a list.
It sequentially checks each element of the list until a
Linear match is found or the whole list has been searched.
Step through array of records, one at a time.
Search Look for record with matching key.
Search stops when
record with matching key is found
or when search has examined all records without
success.
Linear search can be broken down into the following
steps:
Example
Example
Binary search is a search algorithm that finds the
position of a target value within a sorted array.
Binary search compares the target value to the
middle element of the array.
Example
Example
END