Why is time complexity generally considered more important than space complexity in algorithm analysis?
Space complexity cannot be expressed using Big-O notation.
Space complexity is irrelevant in modern computing.
Time complexity is always more difficult to analyze.
Modern computers have abundant memory, while efficient time utilization often remains a bottleneck.
Which of the following operations generally exhibits O(log n) time complexity in a balanced binary search tree?
Calculating the height of the tree
Inserting a new element
Finding the minimum element
Printing all elements in sorted order
Consider a dynamic array implementation where resizing to double the capacity takes O(n) time. If we perform 'n' insertions sequentially, what is the amortized time complexity per insertion?
O(n log n)
O(1)
O(log n)
O(n)
You have two algorithms, A and B, for the same problem. A has a time complexity of O(n log n) and Ω(n), while B has a time complexity of O(n^2) and Ω(log n). Which of the following statements is always true?
We cannot definitively compare the performance of the two algorithms based on the given information.
Algorithm A is faster than Algorithm B for sufficiently large input sizes.
Algorithm A is faster than Algorithm B for all input sizes.
Algorithm B is faster than Algorithm A for all input sizes.
Consider a social network graph with V users and E friendships. You want to find the shortest path between two users (A and B) in terms of friendship connections. What is the time complexity of the most efficient algorithm for this scenario in the worst-case?
O(V + E) using Breadth First Search
O(E log V) using Dijkstra's Algorithm with a binary heap
O(V!) using brute-force depth-first search
O(V^2) using Floyd-Warshall Algorithm
You need to sort a large dataset. Algorithm A has a time complexity of O(n log n) and a space complexity of O(1). Algorithm B has a time complexity of O(n) but requires O(n) extra space. Which algorithm is preferable if memory usage is severely constrained?
Both are equally preferable
Insufficient information to determine
Algorithm B
Algorithm A
A recursive function has a base case that executes in O(1) time. For each recursive step, it makes 3 recursive calls with input size n/2. What is the overall time complexity of this function?
O(n^log_2(3))
O(n^2)
You need to choose an algorithm for a real-time system with strict timing constraints. Algorithm X has a time complexity of O(n log n) in the worst case and Θ(1) in the best case. Algorithm Y has a time complexity of Θ(n) in all cases. Which algorithm is a safer choice and why?
Algorithm Y, because its time complexity is consistent and predictable.
Algorithm X, because its best-case complexity is excellent.
Neither algorithm is suitable for a real-time system.
Both algorithms are equally suitable for a real-time system.
An algorithm processes an input array of size 'n'. It iterates through the array once, performing constant-time operations for each element. Inside the loop, it calls a helper function that has a time complexity of Θ(log n). What is the overall time complexity of this algorithm?
You are given a sorted array of n integers. You want to determine if there exists a pair of elements in the array that sum up to a specific target value. Which algorithm provides the most efficient time complexity?
Sorting the array and then using binary search
Using two pointers, one at the beginning and one at the end of the array
Nested loops to check all pairs
Using a hash table to store seen elements