Q. What is the space complexity of an array of size n?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n^2)
Solution
An array of size n requires O(n) space to store its elements.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the time complexity of appending an element to the end of a dynamic array?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n^2)
Solution
Appending an element to a dynamic array can take O(n) time in the worst case when resizing is needed.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the time complexity of finding the maximum element in a linked list?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n^2)
Solution
Finding the maximum element in a linked list requires traversing all elements, resulting in O(n) time complexity.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the time complexity of inserting an element at a specific index in an array?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n^2)
Solution
Inserting an element at a specific index in an array requires shifting elements, which takes O(n) time in the worst case.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the time complexity of reversing a linked list?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n^2)
Solution
Reversing a linked list requires visiting each node once, resulting in O(n) time complexity.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the time complexity of searching for an element in an unsorted array?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n^2)
Solution
Searching for an element in an unsorted array requires checking each element, resulting in O(n) time complexity.
Correct Answer:
B
— O(n)
Learn More →
Showing 1 to 6 of 6 (1 Pages)