10 80 03 09 55 32 100 07 05 02 12 65 63 22 92
10 is found at index 0
05 is found at index 8
76 is not found
85 is not found
200 is not found
O(N) where N is the number of elements in the array you are searching.So it has linear complexity.
A binary search is much faster.
What you're describing is called a sequential search or linear search.
binary search system
Binary Search Algorithm
O(N) where N is the number of elements in the array you are searching.So it has linear complexity.
In computer science, linear search or sequential search is a method for finding a particular value in a list, that consists of checking every one of its elements, one at a time and in sequence, until the desired one is found.[1]Linear search is the simplest search algorithm; it is a special case of brute-force search. Its worst case cost is proportional to the number of elements in the list; and so is its expected cost, if all list elements are equally likely to be searched for. Therefore, if the list has more than a few elements, other methods (such as binary search or hashing) will be faster, but they also impose additional requirements. (Source: Wikipedia)
A binary search is much faster.
What you're describing is called a sequential search or linear search.
The time complexity of a ternary search algorithm is O(log3 n), where n is the number of elements in the array being searched.
The running time of the binary search algorithm is O(log n), where n is the number of elements in the sorted array being searched.
The time complexity of a binary search algorithm is O(log n), where n is the number of elements in the sorted array being searched.
If this is a homework related question, you really should consider trying to solve it yourself before looking at this answer. Otherwise, the value of the lesson, and the reinforcement provided by the assignment, will be lost to you. In a sequential search, where the elements are in a uniformly random distribution, the average number of comparisions to find a particular element is one half of the number of elements. Stated another way... In a sequential search, where the elements are in an arbitrary distribution, the average number of comparisions to find a random element is one half of the number of elements.
The best search algorithm to use for an unsorted array is linear search. It involves checking each element in the array one by one until the desired element is found. This algorithm has a time complexity of O(n), where n is the number of elements in the array.
The time complexity of a binary search algorithm in computer science is O(log n), where n is the number of elements in the sorted array being searched.
The linear search algorithm is a special case of the brute force search.
The best search algorithm to use for a sorted array is the binary search algorithm.