Eduqas A-Level Computer Science A500QS
Data Structures: Arrays, Records and Hash Tables
Stacks, Queues, Linked Lists and Trees
Boolean Logic and Simplification
Algorithms, Pseudo-Code and Programming Constructs
Variables, Scope, Parameters and Identifiers
Recursion and Modular Programming
Sorting Algorithms
Searching and Shortest-Path Algorithms
Big O Notation and Algorithm Efficiency
Validation, Verification and Testing
Data Compression
Programming Paradigms and Computer Languages
Systems Analysis, Maintenance and Documentation
System Design and Human-Computer Interaction
Software Engineering Tools and Translators
Computing, Society and the Law
Computer Architecture, the Processor and Assembly Language
Input, Output and Secondary Storage
Networks, Protocols and the Internet
Data Transmission and Network Performance
Number Systems and Binary Arithmetic
Data Types, Characters and Floating Point
Files, Records and File Organisation
Databases, Normalisation and Entity Modelling
SQL, Big Data and Distributed Systems
The Operating System and Its Modes
Interrupts, Memory Management and Scheduling
Types of Software System
Data Security, Cryptography and Attack
Searching and Shortest-Path Algorithms
Comparing linear and binary search
- 3 things to know
- Component 1
Overview
The two searches set against each other on how they narrow the data, on comparisons needed in the worst case, on memory, and on when the difference is worth anything.
What you need to know
Answer each one before you reveal it.
State the key difference in how linear and binary searches narrow the data.
Compare the time complexity of the two searches.
Questions from this subtopic
Each one with the model answer underneath.
- 1
State the key difference in how linear and binary searches narrow the data.
Model answer
A linear search removes one item from consideration per comparison. A binary search removes half of the remaining items per comparison.
- 2
Compare the time complexity of the two searches.
Model answer
A linear search is O(n) and a binary search is O(log n). The gap widens rapidly as the list grows.
- 3
For a sorted list of 16 items, how many comparisons does each search need in the worst case?
Model answer
A linear search needs 16 comparisons in the worst case. A binary search needs only 5, since each comparison leaves at most half of the items.
- 4
Which search is faster on a list of eight items, and does the difference matter?
Model answer
A binary search needs at most four comparisons against eight for a linear search. The difference is negligible on such a short list.
- 5
Why can a linear search be quicker overall on a small unsorted list?
Model answer
Sorting the list first costs more than the few comparisons a linear search would need. The saving from a binary search appears only on larger data.
- 6
Which search would you use on a telephone directory, and why?
Model answer
A binary search suits a directory because the entries are already in alphabetical order. Very few comparisons are needed even for millions of names.
Other ways to work this
The same content, four other ways.
What is inside Levo
Six ways to work the same material.
Every question in Searching and Shortest-Path Algorithms, on a schedule.
Attempt a question from memory, write the correct version, then attempt it again. Levo records the jump between your first attempt and your last, and brings each question back on the day you are due to forget it.
Or £46 a year, about £3.83 a month. Cancel anytime.