CS Thinking / supporting

Linear Search

Also known as: sequential search

principle

A search algorithm that checks each element in a list one by one until the target is found. Works on unsorted data; baseline to compare against more efficient algorithms.

๐Ÿ’ก Intuition

Looking for your keys by checking every pocket and drawer in order.

Core Idea

Simple but slow for large lists โ€” must check up to every element in the worst case.

๐Ÿ”ฌ Example

Find 37 in [56,12,37,5,23]: check 56 (no), 12 (no), 37 (yes) โ€” found in 3 steps.

๐ŸŽฏ Why It Matters

Works on unsorted data; baseline to compare against more efficient algorithms.

โš ๏ธ Common Confusion

Linear search works on any list; binary search is faster but requires sorted data.

Related Concepts

Prerequisites

How Linear Search Connects to Other Ideas

To understand linear search, you should first be comfortable with searching and array. Once you have a solid grasp of linear search, you can move on to binary search and efficiency.

Go Deeper

Frequently Asked Questions

What is Linear Search in CS Thinking?

A search algorithm that checks each element in a list one by one until the target is found.

Why is Linear Search important?

Works on unsorted data; baseline to compare against more efficient algorithms.

What do students usually get wrong about Linear Search?

Linear search works on any list; binary search is faster but requires sorted data.

What should I learn before Linear Search?

Before studying Linear Search, you should understand: searching, array.