WJEC A-Level Computer Science 601-5345-3
Hardware: Architecture, Memory and Storage
Networks and Data Transmission
Logic Gates and Boolean Algebra
Data Representation and Data Types
Data Structures
Organisation of Data: Files and Records
Database Systems
The Operating System
Algorithms and Programs
Principles of Programming
Systems Analysis
Software Engineering and Program Construction
Types of Software System
Practical Programming
Data Security and Integrity
Computing, Society and the Law
Advanced Data Structures and Logic
Recursion, Sorting and Searching
Programming Paradigms and Translators
System Design and Human-Computer Interaction
Software Engineering Tools and Professional Practice
Advanced Architecture and Assembly Language
Communication Networks and File Organisation
Number Representation and Floating Point
Databases and Distributed Systems
Operating System Management
Software Systems and Applications
Data Security, Cryptography and Attack
Recursion, Sorting and Searching
Searching and shortest-path algorithms
- 3 things to know
- A2 Unit 3
Overview
Recall questions on the complexity of linear and binary search and why, the comparisons needed on a million items, when linear beats binary, why binary needs an array, what Dijkstra's algorithm records and why it can finalise the smallest distance, negative weights, a worked shortest route, and A*.
What you need to know
Answer each one before you reveal it.
State the complexity of a binary search and explain why it has that complexity.
State the greatest number of comparisons a binary search makes on a sorted list of 1,000,000 items.
Questions from this subtopic
Each one with the model answer underneath.
- 1
State the complexity of a linear search and explain why it has that complexity.
Model answer
A linear search is O(n), because in the worst case every one of the n items has to be examined before the answer is known.
- 2
State the complexity of a binary search and explain why it has that complexity.
Model answer
A binary search is O(log n), because every comparison discards half of the items still under consideration.
- 3
State the greatest number of comparisons a binary search makes on a sorted list of 1,000,000 items.
Model answer
2¹⁹ is 524,288 and 2²⁰ is 1,048,576, so at most 20 comparisons are needed.
- 4
How many further comparisons does a binary search need when the list it is given is doubled in length?
Model answer
Just one more, because that single extra comparison halves the doubled list back to its original length.
- 5
Under what conditions does a linear search beat a binary search?
Model answer
A linear search wins on a very short list, on a list that is not in order, and wherever the cost of sorting the list first would outweigh the saving.
- 6
Why must a binary search be given a list held in an array rather than in a linked list?
Model answer
A binary search has to jump straight to the midpoint, and only an array allows a position to be reached by calculation rather than by following pointers from the start.
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 Recursion, Sorting and Searching, 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.