B2.4 Programming algorithmsB2.4.2

Linear Search and Binary Search

Construct and trace algorithms to implement a linear search and a binary search for data retrieval

SL + HL≈ 60 minCommand term: ConstructPremium

In this lesson

  • Constructing a linear search and a binary search in Java and Python
  • Tracing a binary search with low, mid and high
  • Comparing the efficiency of the two searches
  • Choosing a search technique based on the data and the efficiency required

This lesson is part of Premium

Every topic has one free lesson. Premium unlocks every interactive lesson, the exam-style questions at the end of each one, and the rest of Praxis IB.

What's inside

  1. LearnTwo ways to search
  2. CodeLinear search
  3. CodeBinary search
  4. LabSearch step by step
  5. CheckTrace a binary search
  6. LearnComparing the two searches
  7. CheckQuick check
  8. LearnChoosing a search technique
  9. ExamWorked exam answer
  10. ReviewMistakes examiners see
  11. Exam practiceExam-style questions

Ends with 4 exam-style questions worth 13 marks, with a self-marking markscheme.