What is the time complexity of adding an element at the end of a dynamic array (ArrayList in Java, vector in C++) if there is enough capacity?
O(1)
O(n)
O(n log n)
O(log n)
Which time complexity is represented by an algorithm that iterates through a list of size n and performs a constant time operation in each iteration?
O(n^2)
Why is understanding time complexity crucial in algorithm analysis?
To predict how the performance of an algorithm scales with larger inputs
To compare the aesthetic quality of different algorithms
To determine the exact execution time of an algorithm
To calculate the cost of developing an algorithm
If an algorithm's time complexity is O(n^2), what can you conclude about its best-case time complexity?
It is always constant, i.e., O(1).
It is Ω(n^2).
It is also O(n^2).
It cannot be determined from the given information.
Which of the following best describes the relationship between benchmarking and optimizing code for better time complexity?
Benchmarking is done after optimization to verify the improvements.
Benchmarking is a type of optimization technique.
Optimization is done after benchmarking to identify areas for improvement.
Benchmarking and optimization are independent processes.
Which data structure, when used for searching, can potentially improve the time complexity from O(n) to O(log n)?
Array
Queue
Linked List
Binary Tree
Which notation is most useful when analyzing the average-case time complexity of an algorithm, considering all possible inputs?
All notations are equally useful for average-case analysis.
Big-O (O)
Little-o (o)
Big Theta (Θ)
If an algorithm has a time complexity of O(n log n), what can you infer about its runtime as the input size doubles?
It increases exponentially
It increases slightly more than double
It increases by a factor of log n
It remains constant
What is the time complexity of an algorithm with nested loops, where each loop iterates n times?
O(n^3)
Which notation provides both an upper and lower bound on the growth of a function, implying the function grows at the same rate as the specified function?
Big Omega (Ω)
Little-omega (ω)