AP Computer Science Principles Flashcards: Binary Search

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.

QUESTION

Determine the middle index for 'low' = 2, 'high' = 6.

Tap card or press Space to flip

ANSWER

Middle index = 4. Using the formula (2+6)/2=4(2 + 6) / 2 = 4.

1 / 40

AP Computer Science Principles: Algorithms and Programming

All flashcards

40 cards

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.

How to use these flashcards

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.

Practice questions

1 of 14Practice questions for this set
A database stores sorted usernames array ["adam", "bella", "carlos", "dina", "eli", "fatima", "gwen", "hugo", "ivan"] and searches for target "fatima" using iterative binary search; midpoint is (low+high)/2\lfloor(\text{low}+\text{high})/2\rfloor, comparing strings alphabetically. Steps: low=0, high=8, mid=4 ("eli") < "fatima" so low=5; next mid=(5+8)/2\lfloor(5+8)/2\rfloor=6 ("gwen") > "fatima" so high=5; next mid=(5+5)/2\lfloor(5+5)/2\rfloor=5 ("fatima") found. Refer to the array provided above. How many iterations are required to locate the target element using binary search?
Choose an answer

Keep your progress across every deck

Free account · cards you mark are saved to it