An algorithm processes an input of size 'n' by dividing it in half repeatedly until the size becomes 1. What is the most likely time complexity of this algorithm?
O(log n)
O(n)
O(n^2)
O(n log n)
What is the Big-O notation of an algorithm that iterates through an array of size 'n' twice in nested loops?
O(1)
What is the time complexity of Dijkstra's algorithm for finding the shortest path in a graph with V vertices and E edges using an adjacency list and a priority queue?
O(E log V)
O(V log E)
O(V^2)
O(V + E)
Which of the following sorting algorithms has the best average-case time complexity?
Merge Sort
Bubble Sort
Insertion Sort
Selection Sort
You have an algorithm with a time complexity of O(2^n). If you double the input size, how would you expect the execution time to be affected?
It increases exponentially.
It doubles.
It increases by a factor of n.
It remains roughly the same.
Consider a binary search algorithm on a sorted array. In the worst-case scenario, how many comparisons are required to find a target element?
n/2
n
logâ‚‚(n) + 1
1
A linear search algorithm iterates through an unsorted array to find a target element. What is its average-case time complexity?
O(n²)
What does it mean for an algorithm to have a time complexity of Θ(1)?
The runtime is constant and independent of the input size.
The algorithm's runtime is unpredictable and varies greatly with different inputs.
The runtime grows linearly with the input size.
The algorithm is guaranteed to be the fastest possible solution for the problem.
The Floyd-Warshall algorithm is used to find the shortest path between:
A vertex and all other vertices in a graph
All pairs of vertices in a graph
Two specified vertices in a graph
None of the above
What is the time complexity of inserting an element at the beginning of a singly linked list?