AP Computer Science Principles Flashcards: Algorithmic Efficiency

Study Algorithmic Efficiency 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

What is the time complexity of heap sort?

Tap card or press Space to flip

ANSWER

O(n log n)O(n \text{ log } n). Maintains heap property through logarithmic operations.

1 / 39

AP Computer Science Principles: Algorithms and Programming

All flashcards

39 cards

What this deck covers

This deck focuses on Algorithmic Efficiency, 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 17Practice questions for this set
A smartwatch app computes Fibonacci numbers for animations; it may request n up to 45, and each computation must finish under 0.1 seconds. Two approaches are given: Pseudocode (Naive Recursion):
FIB_RECURSIVE(n)
  IF n <= 1
    RETURN n
  RETURN FIB_RECURSIVE(n-1) + FIB_RECURSIVE(n-2)
Time complexity: O(2n)O(2^n) Pseudocode (Dynamic Programming):
FIB_DP(n)
  IF n <= 1
    RETURN n
  prev <- 0
  curr <- 1
  FOR i <- 2 TO n
    next <- prev + curr
    prev <- curr
    curr <- next
  RETURN curr
Time complexity: O(n)O(n) Considering the time complexities mentioned, which algorithm has a lower time complexity for large inputs?
Choose an answer

Keep your progress across every deck

Free account · cards you mark are saved to it