Binary Search (OCR A-Level Computer Science): Flashcards

📚Flashcards
Binary Search
Sign up to keep revising.Create a free account to study more flashcards and track your progress.

Practise the cards

12 cards from this deck

Show

Binary Search definition

Efficient algorithm to find target position in sorted dataset

Pre-condition for Binary Search

Data must be sorted

Binary Search best case time complexity

O(1)O(1) - target is middle element

Binary Search worst case time complexity

O(logn)O(\log n) - halves search space each step

Binary Search iterative space complexity

O(1)O(1)

Binary Search recursive space complexity

O(logn)O(\log n) due to call stack

Action when target < middle in Binary Search

Search left half

Action when target > middle in Binary Search

Search right half

Binary Search vs Linear Search for large datasets

Binary Search is much faster

Why Binary Search fails on unsorted data

Only works on sorted data, gives incorrect results

Recursive Binary Search base condition

Return -1 when low > high (target not found)

How Binary Search reduces search space

Divides search interval in half each iteration

Explore OCR A-Level Computer Science Revision Notes by Topics

Explore OCR A-Level Computer Science Model Answers by Topics

Explore OCR A-Level Computer Science Quizzes by Topics

Explore OCR A-Level Computer Science Exam Questions by Topics

Join 100,000+ A-Level students studying Flashcards with us.

Select your subjects, and get access to A+ resources today.