Developing Algorithms (College Board AP® Computer Science Principles): Flashcards

1/13

0Still learning

Know0

  • True or False?

    Most problems can only be solved by one correct algorithm.

Cards in this collection (13)

  • True or False?

    Most problems can only be solved by one correct algorithm.

    False.

    Most problems can be solved using more than one algorithm, each taking a different approach to reach the same goal.

  • Different correct algorithms for the same problem can have different ____________.

    Different correct algorithms for the same problem can have different efficiencies.

  • Name two trade-offs to evaluate when choosing between algorithms.

    Choosing between algorithms involves trade-offs such as readability, efficiency, and correctness.

  • Define logically equivalent (algorithms).

    Two algorithms are logically equivalent if they produce the same output for every possible input.

  • Write a single Boolean assignment that is logically equivalent to this code segment.

    IF(score ≥ 50)
    
    {
    
       pass ← true
    
    }
    
    ELSE
    
    {
    
       pass ← false
    
    }

    The logically equivalent assignment is pass ← (score ≥ 50), which gives the same value of pass for every input.

  • Name three ways that algorithms can be created.

    Algorithms can be created from an idea, by combining existing algorithms, or by modifying existing algorithms.

  • Name three benefits of building programs from existing correct algorithms.

    Using existing correct algorithms reduces development time, reduces testing, and simplifies the identification of errors.

  • True or False?

    Algorithms that appear similar always produce the same results.

    False.

    Algorithms that appear similar can yield different side effects or results.

  • Name two common algorithms that appear across many programs.

    Common algorithms include finding the maximum or minimum value, computing the sum or average, checking whether an integer is evenly divisible by another, and determining a robot's path through a maze.

  • Give an example of modifying an existing algorithm to fit a new problem.

    For example, a linear search that returns the first match can be modified to return a count of all matches.

  • Define optimization (of an algorithm).

    Optimization is modifying an algorithm to reduce unnecessary steps.

  • Name two strategies for optimizing an algorithm.

    Optimization strategies include:

    • Exiting a loop early once the answer is found

    • Storing results to avoid redundant calculations

    • Choosing a more efficient algorithm, such as binary search over linear search for sorted data

  • When does the efficiency of an algorithm matter most?

    Efficiency matters most when working with large data sets, where small differences in approach cause significant differences in execution time.

Sign up to unlock flashcards

or