Key Concepts

Review core concepts you need to learn to master this subject

Searching for smallest or largest value using linear search

Linear search can be used to search for the smallest or largest value in an unsorted list rather than searching for a match. It can do so by keeping track of the largest (or smallest) value and updating as necessary as the algorithm iterates through the dataset.

Create a variable called max_value_index    
Set max_value_index to the index of the first element of the search list
  For each element in the search list
    if element is greater than the element at max_value_index
      Set max_value_index equal to the index of the element
return max_value_index
Linear Search: Conceptual
Lesson 1 of 4

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo