Algorithmic Efficiency - AP Computer Science Principles
- What is the time complexity of heap sort?
- . Maintains heap property through logarithmic operations.
- What is the Big O notation for an algorithm with constant time?
- . Operation takes same time regardless of input size.
- Identify the time complexity of Kruskal's algorithm.
- . Sorting edges dominates the union-find operations.
- Find the time complexity of the worst case of bubble sort.
- . Compares adjacent pairs through nested iterations.
- State the time complexity of selection sort.
- . Nested loops to find minimum and swap elements.
- Identify the Big O notation for matrix multiplication.
- . Three nested loops for standard multiplication algorithm.
- Identify the Big O notation for a bubble sort algorithm.
- . Nested loops create quadratic growth pattern.
- State the Big O notation for a binary search algorithm.
- . Eliminates half of remaining elements each iteration.
- Identify the time complexity for depth-first search (DFS).
- . Visits each vertex and edge exactly once.
- What is the time complexity of a naive string matching algorithm?
- , where is text length and is pattern length. Compares pattern at every possible text position.
- What is the Big O notation for an algorithm with logarithmic time complexity?
- . Search space halves with each comparison step.
- State the Big O notation for searching an unsorted list.
- . Must examine every element without ordering advantage.
- Identify the Big O notation for the best case of quicksort.
- . Good pivot creates balanced recursive partitions.
- What is the space complexity of an algorithm?
- It measures the memory usage of an algorithm. Tracks additional storage beyond input data.
- What does Big O notation describe?
- It describes the upper limit of an algorithm's complexity. Represents worst-case performance as input size grows.
- What is the time complexity of a merge sort algorithm?
- . Divide-and-conquer with linear merge operations.
- Which algorithm has a time complexity of ?
- Linear search algorithm. Checks each element once in worst case.
- What is the Big O notation for Fibonacci sequence using recursion?
- . Each call branches into two recursive calls.
- Identify the Big O notation for insertion sort in the best case.
- . Already sorted array requires only single pass.
- What is the time complexity of the Floyd-Warshall algorithm?
- . All-pairs shortest path with triple nested loops.
- What is the time complexity of breadth-first search (BFS)?
- . Explores all vertices and their adjacent edges.
- Find and correct the error: 'The time complexity of merge sort is .'
- Correct: 'The time complexity of merge sort is .'. Merge sort consistently divides and merges efficiently.
- What is the average case time complexity of quicksort?
- . Balanced partitioning creates optimal divide-and-conquer.
- State the Big O notation for a depth-first search (DFS) space complexity.
- . Recursion stack depth limited by vertex count.
- Identify the time complexity of a hash table search operation.
- . Direct access through hash function calculation.
- Identify the Big O notation for the average case of bubble sort.
- . Adjacent swaps still require quadratic comparisons.
- What does the term 'polynomial time' mean in algorithmic complexity?
- It means time complexity is for constant . Runtime bounded by polynomial function of input size.
- Find and correct the error: 'A binary search has complexity.'
- Correct: 'A binary search has complexity.'. Binary search divides search space logarithmically.
- What is the definition of algorithmic efficiency?
- Algorithmic efficiency measures resource usage. Focuses on time and space usage as performance metrics.
- Identify the time complexity of Prim's algorithm using a priority queue.
- . Priority queue operations dominate edge processing time.
- What is the worst-case time complexity of insertion sort?
- . Comparisons increase quadratically for reverse-sorted input.
- Find and correct the error: 'BFS has a space complexity of .'
- Correct: 'BFS has a space complexity of .'. Queue stores vertices, not edges during traversal.
- Identify the time complexity of the Bellman-Ford algorithm.
- . Relaxes edges multiple times across all vertices.
- State the Big O notation for a linear search algorithm.
- . Examines each element sequentially until found.
- What is the space complexity of breadth-first search (BFS)?
- . Queue size bounded by number of vertices.
- State the Big O notation for the worst case of quicksort.
- . Poor pivot selection leads to unbalanced partitions.
- What is the time complexity of Dijkstra's algorithm?
- . Uses adjacency matrix for dense graph representation.
- What is the space complexity of a recursive algorithm using stack?
- . Call stack grows proportionally with recursion depth.
- State the Big O notation for an exponential time algorithm.
- . Runtime doubles with each additional input element.