Free Online Flashcard Deck

08 Searching Algorithms Free Online FlashCards

Study 08 Searching Algorithms with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What does sequential search do?

Back

Sequential search checks elements one at a time from the beginning until it finds the target or reaches the end.

02
Front

Does sequential search require sorted data?

Back

No. Sequential search works on unsorted collections because it checks each element directly.

03
Front

What are sequential search’s time complexities?

Back

For an array of size nn, sequential search has best-case Θ(1)\Theta(1), average-case Θ(n)\Theta(n), and worst-case Θ(n)\Theta(n) time.

04
Front

What invariant proves iterative sequential search?

Back

A loop invariant states that before each iteration, every position before the current index has been checked and does not contain the target.

05
Front

How does binary search reduce its search space?

Back

Binary search compares the target with a middle element, then discards the half that cannot contain the target.

06
Front

What assumptions does binary search require?

Back

Binary search requires sorted data, compatible comparisons, efficient middle-element access, stable ordering during the search, and a consistent boundary convention.

07
Front

What is iterative binary search’s complexity on an array?

Back

For an array of size nn, iterative binary search takes Θ(log⁡n)\Theta(\log n) time in the average and worst cases, with Θ(1)\Theta(1) extra space.

08
Front

What does binary search’s half-open interval mean?

Back

The half-open interval [low,high)[low, high) includes lowlow and excludes highhigh. The initial interval is [0,length⁡(A))[0, \operatorname{length}(A)).

09
Front

Why compute binary search’s midpoint this way?

Back

Use low+(high−low)//2low + (high - low) // 2, which avoids the potential fixed-width integer overflow of (low+high)//2(low + high) // 2.

10
Front

Which values are checked when finding 2323 in the example array?

Back

For [3,8,12,17,23,31,44][3, 8, 12, 17, 23, 31, 44] and target 2323, binary search checks 1717, then 3131, then 2323.

11
Front

What invariant proves half-open binary search?

Back

For the half-open implementation, the invariant is: if the target occurs, it must occur within the current interval [low,high)[low, high).

12
Front

How do recursive and iterative binary search differ in space?

Back

Recursive binary search uses Θ(log⁡n)\Theta(\log n) stack space, while iterative binary search uses Θ(1)\Theta(1) auxiliary space.