Skip to content
Computer Science · Class 11 · Computational Thinking and Foundations · Term 1

Basic Search Algorithms: Linear Search

Students will learn and implement the linear search algorithm, analyzing its steps and efficiency.

CBSE Learning OutcomesCBSE: Algorithm Design and Efficiency - Class 11

About This Topic

Linear search is a fundamental algorithm where we check each element in a list sequentially until we find the target or reach the end. Students start by understanding its simple steps: begin at the first position, compare the element with the target, move to the next if no match, and stop when found or list ends. This method requires no sorting, making it straightforward for unsorted data.

Next, analyse efficiency through time complexity. Best case occurs with target at the first position, needing one comparison. Worst case scans the entire list, needing n comparisons for n elements. Average case assumes uniform distribution, around n/2 comparisons. Discuss scenarios: suitable for small lists or unsorted data, but inefficient for large datasets.

Active learning benefits this topic as students implement the algorithm on paper or code, predict outcomes for varied inputs, and compare run times, building intuition for efficiency analysis.

Key Questions

  1. Explain the step-by-step process of a linear search.
  2. Analyze the best-case, worst-case, and average-case scenarios for linear search.
  3. Predict when a linear search might be an acceptable or unacceptable solution.

Learning Objectives

  • Demonstrate the step-by-step execution of a linear search algorithm with a given list and target value.
  • Calculate the number of comparisons for best-case, worst-case, and average-case scenarios for a linear search.
  • Compare the efficiency of linear search against other potential search methods for different data sizes and states.
  • Evaluate the suitability of linear search for specific problem contexts, justifying the choice based on efficiency analysis.

Before You Start

Introduction to Algorithms

Why: Students need a basic understanding of what an algorithm is and its purpose before learning specific algorithms like linear search.

Data Types and Lists

Why: Familiarity with representing data in lists or arrays is essential for implementing and understanding sequential searching.

Basic Programming Constructs (Loops and Conditionals)

Why: Implementing linear search requires the use of loops to iterate through the list and conditional statements to check for matches.

Key Vocabulary

Linear SearchA sequential search algorithm that checks each element in a list one by one until the target element is found or the list ends.
Target ElementThe specific value or item that the search algorithm is trying to locate within a dataset.
Time ComplexityA measure of how the runtime of an algorithm grows as the input size increases, often expressed using Big O notation.
Best-Case ScenarioThe input arrangement that allows the algorithm to complete in the minimum possible number of operations.
Worst-Case ScenarioThe input arrangement that requires the maximum number of operations for the algorithm to complete.

Watch Out for These Misconceptions

Common MisconceptionLinear search works only on sorted lists.

What to Teach Instead

Linear search requires no sorting; it checks elements sequentially regardless of order.

Common MisconceptionLinear search is always inefficient.

What to Teach Instead

It suits small or unsorted lists well; inefficiency shows mainly with large datasets.

Common MisconceptionBest case and average case are the same.

What to Teach Instead

Best case is one comparison; average case is about n/2 for uniform targets.

Active Learning Ideas

See all activities

Real-World Connections

  • Librarians use linear search principles when manually checking shelves for a specific book title if the catalogue system is unavailable or if they need to verify a physical location.
  • A customer service representative might perform a linear search through a list of recent customer orders to find a specific order ID when a customer calls with an inquiry, especially if the database search is slow.
  • When looking for a specific contact in a small, unsorted phone list on paper, one might naturally employ a linear search, checking each entry from top to bottom.

Assessment Ideas

Quick Check

Present students with a small, unsorted list of numbers (e.g., [15, 7, 22, 4, 18]) and a target value (e.g., 22). Ask them to write down each step of the linear search, indicating the comparisons made and the final position of the target. Also, ask them to state the number of comparisons performed.

Discussion Prompt

Pose the question: 'Imagine you have a list of 1000 student roll numbers and you need to find roll number 750. Would linear search be a good choice? Why or why not? What would make it a good choice, and what would make it a bad choice?' Facilitate a class discussion on their reasoning.

Exit Ticket

On a slip of paper, ask students to define 'worst-case scenario' for linear search in their own words and provide an example list and target value that would trigger this scenario.

Frequently Asked Questions

How do I introduce linear search to beginners?
Begin with everyday examples like finding a book on a shelf by checking each one. Draw a small list on the board, trace the steps live. Then, have students trace on paper. This builds familiarity before coding. Reinforce with key questions on cases.
What tools help teach efficiency analysis?
Use Python's time module for simple timings on lists of size 10, 100, 1000. Or, manual counting sheets. CBSE aligns with analysing best, worst, average cases. Graphs from results clarify O(n) growth.
Why include active learning for linear search?
Active learning lets students code and test the algorithm themselves, predict comparisons for inputs, and debate trade-offs. This hands-on approach deepens grasp of steps and efficiency over passive notes. It matches CBSE standards by linking theory to practice, boosting retention.
When is linear search preferable over others?
Choose it for small lists under 100 elements or unsorted data where sorting costs more. For frequent searches on static data, consider sorting first. Key questions guide predicting acceptability.