0% found this document useful (0 votes)
8 views2 pages

Linear - and - Binary - Search ASTAR P3 Notes

The document explains linear and binary search algorithms, detailing their processes, efficiency, and conditions for use. Linear search is less efficient (O(n)) and works on both sorted and unsorted lists, while binary search is more efficient (O(log n)) but requires a sorted list. It also discusses scenarios where each search method is preferable and the implications of time complexity.

Uploaded by

subrittishrestha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Linear - and - Binary - Search ASTAR P3 Notes

The document explains linear and binary search algorithms, detailing their processes, efficiency, and conditions for use. Linear search is less efficient (O(n)) and works on both sorted and unsorted lists, while binary search is more efficient (O(log n)) but requires a sorted list. It also discusses scenarios where each search method is preferable and the implications of time complexity.

Uploaded by

subrittishrestha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

A-Level 9618 Paper 3 - Theoretical Questions on Linear and Binary Search

1. Describe how a linear search algorithm works.


- Goes through each element in a list sequentially.
- Compares each element with the target value.
- Stops when the target is found or end of the list is reached.
- Works on sorted or unsorted lists.
2. Describe how a binary search algorithm works.
- Requires the list to be sorted.
- Repeatedly divides the search range in half.
- Compares the middle element with the target.
- Adjusts search range based on comparison result.
- Stops when value is found or range becomes empty.
3. State the condition(s) necessary for binary search to work.
- The list must be sorted in ascending or descending order.
4. Compare linear search and binary search in terms of efficiency.
- Linear Search: Less efficient, O(n), works on unsorted lists.
- Binary Search: More efficient, O(log n), requires sorted list.
5. Give one reason why binary search may be more efficient than linear search.
- Reduces the search space by half each time, leading to fewer comparisons.
6. Why is binary search not always the better choice?
- Requires sorted list which may take time to prepare.
- Not suitable for small datasets or unsorted data.
7. Example where linear search is better.
- Searching for an item in an unsorted list.
- When list is very small.
8. Identify linear or binary search in a flowchart or code.
- Linear: Scans all items one-by-one.
- Binary: Uses midpoints and halves the list.
9. Trace a binary search algorithm.
- Show changes in low, high, and mid at each step.
- Indicate comparison and updated range.
10. Trace a linear search algorithm.
- Start at index 0, compare each element with target.
- Stop when match is found or end reached.
11. What happens if value not found?
- Linear: Reach end of list, return -1 or 'not found'.
- Binary: Low > High, return -1 or 'not found'.
12. How binary search reduces search space?
- Halves the list in each iteration.
- Search space shrinks exponentially.
13. Why binary search fails on unsorted lists?
- Assumes order for halving logic.
- Wrong elimination may exclude the correct value.
14. Time complexity comparison.
- Linear: Best O(1), Avg/Worst O(n).
- Binary: Best O(1), Avg/Worst O(log n).
15. Meaning of O(n) and O(log n).
- O(n): Time grows linearly with elements.
- O(log n): Time grows logarithmically, fewer steps for
large n.

You might also like