Please enable JavaScript to use CodeHS

CodeHS Glossary


Linear Search General

A search algorithm that searches for a given value in a list of values. It simply starts at index 0 in the list, and loops through the indices in the list until it finds the desired value. Returns the index of the value in the list, -1 if the value doesn't exist. Linear search is less efficient than binary search. Linear search has a Big-Oh runtime of O(n), where n is the length of the list. Pseudocode for Linear Search: ``` for every index in the array: get element at current index if elem == the value we are looking for return the current index return not found ```