What this deck covers
This deck focuses on Binary Search, giving you a quick way to review the definitions, rules, and examples that matter most for AP Computer Science Principles.
Study Binary Search in AP Computer Science Principles with focused flashcards that help you recognize the idea, recall the key rule, and apply it in practice-style prompts.
0% Complete
What happens if the middle element equals the target in binary search?
Tap card or press Space to flip
Returns the middle index. Successful match terminates search with target location.
How well did you know it?
Card 1 / 80
Space to flip · ← / → to move · once flipped, → Got it · ← Still learning
This deck focuses on Binary Search, giving you a quick way to review the definitions, rules, and examples that matter most for AP Computer Science Principles.
Work through these flashcards in short sessions. Try to answer each prompt before flipping the card, then revisit any cards you miss until the explanation feels automatic.
Answer: Returns the middle index. Successful match terminates search with target location.
Answer: Divide and conquer. Repeatedly divides the problem into smaller subproblems.
Answer: Middle index = 4. Using the formula (2+6)/2=4.
Answer: Searching in databases. Efficiently locates records in sorted database indexes.
Answer: A logarithmic search. Uses logarithmic time complexity for efficient searching.
Answer: O(log n). Eliminates half the search space with each comparison.
Answer: By halving the search range each step. Eliminates half the possibilities with each comparison.
Answer: Checks if the element is the target. Performs one comparison to determine success or failure.
Answer: Check the element at 'low' or 'high'. Single element left to verify as target match.
Answer: O(1). Only uses a few variables regardless of dataset size.
Answer: On an unsorted dataset. Binary search assumes sorted order to function correctly.
Answer: Yes, if they are comparable and sorted. Elements must support comparison operators and ordering.
Answer: Finds one occurrence of the target. Standard behavior returns first match found, not all.
Answer: No, uses constant space O(1). Only needs variables for indices, not extra arrays.
Answer: Search the left half of the dataset. Target must be in the smaller half of the remaining elements.
Answer: Search the right half of the dataset. Target must be in the larger half of the remaining elements.
Answer: They define the current search range. Boundaries that shrink with each iteration until target found.
Answer: Directly checks the only element. One comparison determines if target is found.
Answer: By halving the search range each step. Eliminates half the possibilities with each comparison.
Answer: Typically, -1 or null. Standard convention to indicate search failure.
Answer: Middle index = 4. Using the formula (0+8)/2=4.
Answer: Search ends; no new range is needed. Target found means search is complete and successful.
Answer: Directly checks the only element. One comparison determines if target is found.
Answer: Not efficiently due to non-constant time access. Sequential access makes random indexing inefficient.
Answer: Faster on sorted datasets. Logarithmic vs linear time complexity provides significant speedup.
Answer: Using a while loop to adjust 'low' and 'high'. Uses loops to repeatedly narrow the search boundaries.
Answer: Returns the middle index. Successful match terminates search with target location.
Answer: Sorted array or list. Allows constant-time access to any index for comparisons.
Answer: Sorted array or list. Allows constant-time access to any index for comparisons.
Answer: When 'low' exceeds 'high'. Indicates no valid search range remains.
Answer: Faster on sorted datasets. Logarithmic vs linear time complexity provides significant speedup.
Answer: Middle index = 5. Using the formula (3+7)/2=5.
Answer: Requires static datasets. Cannot handle dynamic insertions or deletions efficiently.
Answer: A logarithmic search. Uses logarithmic time complexity for efficient searching.
Answer: Typically, -1 or null. Standard convention to indicate search failure.
Answer: Middle index = 4. Using the formula (0+8)/2=4.
Answer: Search the left half of the dataset. Target must be in the smaller half of the remaining elements.
Answer: Binary requires sorting; linear does not. Binary needs preprocessing while linear works on any order.
Answer: Requires a sorted dataset. Limits use to pre-sorted data structures only.
Answer: Recursion or iterative loops. Essential for implementing the divide-and-conquer strategy.
Answer: Yes, it can be implemented recursively. Natural fit for divide-and-conquer recursive approach.
Answer: It fails to find elements reliably. Ordering assumption is violated, breaking the algorithm.
Answer: Returns -1 or null immediately. No elements exist to search through.
Answer: Recursion or iterative loops. Essential for implementing the divide-and-conquer strategy.
Answer: On an unsorted dataset. Binary search assumes sorted order to function correctly.
Answer: When 'low' exceeds 'high'. Indicates no valid search range remains.
Answer: Middle index = 5. Using the formula (3+7)/2=5.
Answer: Middle index = 2low+high. Formula calculates the midpoint between current boundaries.
Answer: They define the current search range. Boundaries that shrink with each iteration until target found.
Answer: O(log n). Consistently eliminates half the search space each iteration.
Answer: The dataset must be sorted. Binary search relies on ordering to eliminate half the search space.
Answer: Yes, if they are comparable and sorted. Elements must support comparison operators and ordering.
Answer: Requires a sorted dataset. Limits use to pre-sorted data structures only.
Answer: Checks if the element is the target. Performs one comparison to determine success or failure.
Answer: It fails to find elements reliably. Ordering assumption is violated, breaking the algorithm.
Answer: Middle index = 4. Using the formula (2+6)/2=4.
Answer: Binary requires sorting; linear does not. Binary needs preprocessing while linear works on any order.
Answer: Yes, it can be implemented recursively. Natural fit for divide-and-conquer recursive approach.
Answer: Requires static datasets. Cannot handle dynamic insertions or deletions efficiently.
Answer: Search ends; no new range is needed. Target found means search is complete and successful.
Answer: Returns -1 or null immediately. No elements exist to search through.
Answer: The index of the target element. Provides the location where the target was found.
Answer: Frequent sorting is required. Maintaining sorted order becomes costly with many changes.
Answer: The index of the target element. Provides the location where the target was found.
Answer: O(log n). Eliminates half the search space with each comparison.
Answer: Search the right half of the dataset. Target must be in the larger half of the remaining elements.
Answer: Not efficiently due to non-constant time access. Sequential access makes random indexing inefficient.
Answer: No, uses constant space O(1). Only needs variables for indices, not extra arrays.
Answer: O(log n). Consistently eliminates half the search space each iteration.
Answer: Divide and conquer. Repeatedly divides the problem into smaller subproblems.
Answer: Middle index = 2low+high. Formula calculates the midpoint between current boundaries.
Answer: Calculate the middle index of the dataset. Starting point to compare against the target value.
Answer: Searching in databases. Efficiently locates records in sorted database indexes.
Answer: O(1). Only uses a few variables regardless of dataset size.
Answer: Using a while loop to adjust 'low' and 'high'. Uses loops to repeatedly narrow the search boundaries.
Answer: Finds one occurrence of the target. Standard behavior returns first match found, not all.
Answer: Calculate the middle index of the dataset. Starting point to compare against the target value.
Answer: The dataset must be sorted. Binary search relies on ordering to eliminate half the search space.
Answer: Frequent sorting is required. Maintaining sorted order becomes costly with many changes.
Answer: Check the element at 'low' or 'high'. Single element left to verify as target match.