This chapter describes the most common and simplest algorithms used for searching a value in an array and for sorting the elements of an array in ascending or descending order.
To check if a value is stored into an array, we are going to describe the linear and binary search algorithms.
The linear search algorithm (also called sequential search) is the simplest algorithm to search for a value in a nonsorted array. The searched value is compared against the value of each element until a match is found.
In an array of n elements, the maximum number of searches is n. This may occur if the searched value is not found or is equal to the last element.
In the following program, ...