Developing Algorithms - AP Computer Science Principles
Card 1 of 30
What is the purpose of using flowcharts in algorithm design?
What is the purpose of using flowcharts in algorithm design?
Tap to reveal answer
To visually represent the sequence of steps in an algorithm. Shows decision points, loops, and flow direction graphically.
To visually represent the sequence of steps in an algorithm. Shows decision points, loops, and flow direction graphically.
← Didn't Know|Knew It →
Identify the main components of a typical algorithm.
Identify the main components of a typical algorithm.
Tap to reveal answer
Input, process, output. The basic flow: receive data, manipulate it, produce results.
Input, process, output. The basic flow: receive data, manipulate it, produce results.
← Didn't Know|Knew It →
What does 'pseudocode' refer to in algorithm development?
What does 'pseudocode' refer to in algorithm development?
Tap to reveal answer
A high-level description of an algorithm using plain language. Uses structured English to outline algorithm logic before coding.
A high-level description of an algorithm using plain language. Uses structured English to outline algorithm logic before coding.
← Didn't Know|Knew It →
What is the definition of an algorithm?
What is the definition of an algorithm?
Tap to reveal answer
A step-by-step procedure for solving a problem. Algorithms are systematic solutions with clear steps to solve problems.
A step-by-step procedure for solving a problem. Algorithms are systematic solutions with clear steps to solve problems.
← Didn't Know|Knew It →
What is the big-O notation for the worst-case scenario of bubble sort?
What is the big-O notation for the worst-case scenario of bubble sort?
Tap to reveal answer
$O(n^2)$. Requires $n(n-1)/2$ comparisons when array is reverse sorted.
$O(n^2)$. Requires $n(n-1)/2$ comparisons when array is reverse sorted.
← Didn't Know|Knew It →
What is dynamic programming in algorithms?
What is dynamic programming in algorithms?
Tap to reveal answer
A method for solving complex problems by breaking them down. Stores solutions to subproblems to avoid redundant calculations.
A method for solving complex problems by breaking them down. Stores solutions to subproblems to avoid redundant calculations.
← Didn't Know|Knew It →
Identify the algorithm used for finding the minimum spanning tree.
Identify the algorithm used for finding the minimum spanning tree.
Tap to reveal answer
Prim's or Kruskal's algorithm. Finds minimum cost to connect all vertices in graph.
Prim's or Kruskal's algorithm. Finds minimum cost to connect all vertices in graph.
← Didn't Know|Knew It →
What is a heuristic in algorithm design?
What is a heuristic in algorithm design?
Tap to reveal answer
A technique to find solutions faster when classic methods fail. Approximation method when optimal solutions are computationally expensive.
A technique to find solutions faster when classic methods fail. Approximation method when optimal solutions are computationally expensive.
← Didn't Know|Knew It →
Find the output of the algorithm: Input: 4, Output: $x^3$.
Find the output of the algorithm: Input: 4, Output: $x^3$.
Tap to reveal answer
- Substituting $x=4$ into $x^3$ gives $4^3 = 64$.
- Substituting $x=4$ into $x^3$ gives $4^3 = 64$.
← Didn't Know|Knew It →
Which search algorithm operates efficiently on sorted arrays?
Which search algorithm operates efficiently on sorted arrays?
Tap to reveal answer
Binary search. Halves search space each iteration, requiring sorted input.
Binary search. Halves search space each iteration, requiring sorted input.
← Didn't Know|Knew It →
What is the role of a break statement in a loop?
What is the role of a break statement in a loop?
Tap to reveal answer
To terminate the loop prematurely. Exits loop immediately when specific condition is met.
To terminate the loop prematurely. Exits loop immediately when specific condition is met.
← Didn't Know|Knew It →
Which type of loop guarantees execution at least once?
Which type of loop guarantees execution at least once?
Tap to reveal answer
Do-while loop. Condition checked after execution, ensuring one iteration minimum.
Do-while loop. Condition checked after execution, ensuring one iteration minimum.
← Didn't Know|Knew It →
Identify the algorithm that uses a queue to explore nodes in a graph.
Identify the algorithm that uses a queue to explore nodes in a graph.
Tap to reveal answer
Breadth-first search. Queue ensures level-by-level exploration of graph nodes.
Breadth-first search. Queue ensures level-by-level exploration of graph nodes.
← Didn't Know|Knew It →
What is the main advantage of using recursion in algorithms?
What is the main advantage of using recursion in algorithms?
Tap to reveal answer
Simplifies the code for problems that have a recursive structure. Natural fit for tree traversals and mathematical expressions.
Simplifies the code for problems that have a recursive structure. Natural fit for tree traversals and mathematical expressions.
← Didn't Know|Knew It →
Identify the algorithm that builds a sorted array one item at a time.
Identify the algorithm that builds a sorted array one item at a time.
Tap to reveal answer
Insertion sort. Inserts each new element into its correct sorted position.
Insertion sort. Inserts each new element into its correct sorted position.
← Didn't Know|Knew It →
What does the acronym LIFO stand for in data structures?
What does the acronym LIFO stand for in data structures?
Tap to reveal answer
Last In, First Out. Stack behavior where most recent item is removed first.
Last In, First Out. Stack behavior where most recent item is removed first.
← Didn't Know|Knew It →
Which data structure follows the LIFO principle?
Which data structure follows the LIFO principle?
Tap to reveal answer
Stack. Used for function calls, undo operations, and backtracking.
Stack. Used for function calls, undo operations, and backtracking.
← Didn't Know|Knew It →
What is the purpose of a sentinel value in algorithms?
What is the purpose of a sentinel value in algorithms?
Tap to reveal answer
To denote the end of a data structure. Special marker value indicating boundary or termination condition.
To denote the end of a data structure. Special marker value indicating boundary or termination condition.
← Didn't Know|Knew It →
Identify the algorithm that sorts by repeatedly finding the minimum.
Identify the algorithm that sorts by repeatedly finding the minimum.
Tap to reveal answer
Selection sort. Finds smallest element and swaps to correct position repeatedly.
Selection sort. Finds smallest element and swaps to correct position repeatedly.
← Didn't Know|Knew It →
What is the primary use of a hash table in algorithms?
What is the primary use of a hash table in algorithms?
Tap to reveal answer
Efficiently store and retrieve data. Provides constant-time average access using hash functions.
Efficiently store and retrieve data. Provides constant-time average access using hash functions.
← Didn't Know|Knew It →
What is an invariant in the context of algorithms?
What is an invariant in the context of algorithms?
Tap to reveal answer
A condition that remains true throughout the execution. Property that helps prove algorithm correctness and termination.
A condition that remains true throughout the execution. Property that helps prove algorithm correctness and termination.
← Didn't Know|Knew It →
Which data structure is used in depth-first search algorithms?
Which data structure is used in depth-first search algorithms?
Tap to reveal answer
Stack. LIFO structure enables deep exploration before backtracking.
Stack. LIFO structure enables deep exploration before backtracking.
← Didn't Know|Knew It →
What is the time complexity of the insertion sort in the best case?
What is the time complexity of the insertion sort in the best case?
Tap to reveal answer
$O(n)$. Already sorted arrays require minimal comparisons and shifts.
$O(n)$. Already sorted arrays require minimal comparisons and shifts.
← Didn't Know|Knew It →
Identify the algorithm that finds the shortest path in a weighted graph.
Identify the algorithm that finds the shortest path in a weighted graph.
Tap to reveal answer
Dijkstra's algorithm. Uses priority queue to find minimum distances from source.
Dijkstra's algorithm. Uses priority queue to find minimum distances from source.
← Didn't Know|Knew It →
Which sorting algorithm is not based on comparisons?
Which sorting algorithm is not based on comparisons?
Tap to reveal answer
Counting sort. Counts frequency of elements rather than comparing values.
Counting sort. Counts frequency of elements rather than comparing values.
← Didn't Know|Knew It →
Find the big-O notation for the worst-case of linear search.
Find the big-O notation for the worst-case of linear search.
Tap to reveal answer
$O(n)$. Must check every element when target is last or absent.
$O(n)$. Must check every element when target is last or absent.
← Didn't Know|Knew It →
Which algorithm strategy uses a divide-and-conquer approach?
Which algorithm strategy uses a divide-and-conquer approach?
Tap to reveal answer
Merge sort. Recursively splits problems into smaller, manageable subproblems.
Merge sort. Recursively splits problems into smaller, manageable subproblems.
← Didn't Know|Knew It →
Identify the sorting algorithm with the best average-case performance.
Identify the sorting algorithm with the best average-case performance.
Tap to reveal answer
Heapsort, Mergesort, or Quicksort. All three achieve $O(n \log n)$ average performance consistently.
Heapsort, Mergesort, or Quicksort. All three achieve $O(n \log n)$ average performance consistently.
← Didn't Know|Knew It →
What is the time complexity of the quicksort algorithm in the average case?
What is the time complexity of the quicksort algorithm in the average case?
Tap to reveal answer
$O(n , \log n)$. Divides array and partitions around pivot efficiently on average.
$O(n , \log n)$. Divides array and partitions around pivot efficiently on average.
← Didn't Know|Knew It →
Find the result of the algorithm: Input: 3, Output: $x^2$.
Find the result of the algorithm: Input: 3, Output: $x^2$.
Tap to reveal answer
- Substituting $x=3$ into $x^2$ gives $3^2 = 9$.
- Substituting $x=3$ into $x^2$ gives $3^2 = 9$.
← Didn't Know|Knew It →