Search algorithms are typically used in order to retrieve an element from a dataset or to check for the presence of that element. Search algorithms are generally classified into two separate categories: linear search and interval search.
Understanding search algorithms
Linear search
In a linear search algorithm, every element in the slice or array is checked when the slice or array is traversed sequentially. This algorithm isn't the most efficient algorithm since it ranks in at an O(n) complexity because it can traverse every element on the list.
A linear search algorithm can be written simply as an iteration through a slice, as shown in the following code snippet:
func LinearSearch(data []int, searchVal int) bool {
for...