Fiveable
Fiveable

Linear Search

Definition

Linear search is a simple searching algorithm that sequentially checks each element in a list until it finds the target value or reaches the end of the list.

Analogy

Imagine you're looking for your favorite pair of socks in your messy drawer. You start from one end and check each sock until you find the one you want or reach the last sock. This is similar to how linear search works - it checks each element one by one until it finds what it's looking for.

Related terms

Binary Search: Binary search is an efficient searching algorithm that divides a sorted list into two halves and repeatedly narrows down the search range by comparing with the middle element.

Sorting Algorithms: Sorting algorithms are methods used to arrange elements in a specific order, such as ascending or descending. Examples include bubble sort, insertion sort, and merge sort.

Time Complexity: Time complexity measures how long an algorithm takes to run based on its input size. It helps analyze and compare different algorithms' efficiency.



© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.


© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.