Informal Run-Time Analysis - AP Computer Science A
- Identify the Big O for the best-case of insertion sort.
- . Array is already sorted requiring minimal operations.
- Identify the Big O for binary search in a sorted array.
- . Eliminates half the search space each comparison.
- Find the Big O for sorting a linked list using merge sort.
- . Divide and conquer maintains efficient time complexity.
- Identify the Big O for sorting algorithms based on comparisons in the general case.
- . Theoretical lower bound for comparison-based sorting.
- State the Big O notation for heap sort.
- . Maintains heap property with logarithmic operations.
- State the Big O for matrix multiplication of two matrices.
- . Three nested loops for standard algorithm.
- What is the Big O for calculating the power of a number using divide and conquer?
- . Exponentiation by squaring reduces problem size.
- Which Big O notation is typical for a nested loop with two variables?
- . Each element compared with every other element.
- What is the Big O for finding the maximum element in an unsorted array?
- . Must examine every element to find maximum.
- What is the Big O for reversing a string of length ?
- . Must process each character exactly once.
- Identify the Big O for the worst-case of merge sort.
- . Always divides array in half regardless of input.
- What does Big O notation describe?
- Big O describes the upper bound of an algorithm's run-time complexity. It measures how execution time grows with input size.
- Identify the Big O for appending an element to a dynamic array.
- . Amortized constant time for most operations.
- Which Big O notation represents constant time complexity?
- . Execution time stays the same regardless of input size.
- Identify the Big O notation for the Fibonacci sequence using iteration.
- . Single loop calculates each term once.
- What is the Big O notation for accessing an element in an array?
- . Direct index access using memory addresses.
- Find the Big O for the average case of searching in a hash table.
- . Good hash function distributes elements evenly.
- What is the Big O for removing an element from a queue?
- . Direct access to front element in queue structure.
- What is the Big O for traversing all elements in a binary tree?
- . Must visit each node exactly once.
- What is the Big O for deleting an element from a linked list?
- . Must traverse list to find element before deletion.
- State the Big O for calculating the factorial of a number using recursion.
- . Makes one recursive call for each number.
- State the time complexity for adding an element to a stack.
- . Simple operation at the top of the stack.
- State the Big O notation for a linear search algorithm.
- . Must check each element sequentially in worst case.
- State the Big O for computing the greatest common divisor using Euclid's algorithm.
- . Repeatedly divides numbers by their remainder.
- What is the Big O for finding the minimum element in an unsorted array?
- . Must examine every element to find minimum.
- What is the Big O of quicksort in the best case?
- . Efficiently partitions and divides the problem size.
- Find the Big O for the worst-case scenario of quicksort.
- . Poor pivot choice leads to unbalanced partitions.
- What is the Big O for finding an element in an unsorted linked list?
- . Must traverse list sequentially to find element.
- State the Big O notation for bubble sort in the average case.
- . Nested loops compare each element with every other element.
- State the Big O notation of merge sort.
- . Always divides array in half regardless of input.
- State the Big O notation for the best-case scenario of quicksort.
- . Efficiently partitions and divides the problem size.
- Identify the Big O for accessing an element in a hash table in the average case.
- . Good hash function provides direct element access.
- Identify the Big O notation for a loop that halves the input size each iteration.
- . Input size reduces by half each iteration.
- What is the Big O for checking if a number is prime using trial division?
- . Only test divisors up to square root.
- State the Big O for removing the smallest element from a priority queue.
- . Heap maintains order with logarithmic height.
- Identify the Big O for searching in a balanced binary search tree.
- . Tree height is logarithmic when properly balanced.
- Find the Big O for the worst-case of searching in a hash table.
- . All elements may hash to same bucket requiring linear search.
- State the Big O for adding an element to a binary heap.
- . Maintains heap property by bubbling up.