Computer Science · B2.4 Programming Algorithms

B2.4.2 — Linear and Binary Search: Construction and Tracing

Preview

IB DP Computer Science — B2 Programming — Programming algorithms | SL | B2.4.2

📋 What You Will Learn

  • Describe how linear search and binary search retrieve data from a collection
  • Construct both algorithms in IB-style pseudocode, Java and Python
  • Trace both algorithms with full trace tables, including the not-found case
  • State binary search's pre-condition (sorted data) and explain the difference in efficiency — O(n) vs O(log n)
  • Select the appropriate search technique for a given efficiency requirement, e.g. a phone directory searched by name versus by number

📕 Why This Matters To find "Nakamura" in a printed phone book you open near the middle and halve the pages each time — perhaps 15 flips for a whole city. To find who owns the number 555-0192, that same book is useless order-wise: you must scan every entry. Same data, two search

Continue reading the full note