Q. What is the space complexity of a recursive depth-first search (DFS) on a binary tree?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
The space complexity is O(n) due to the recursion stack in the worst case when the tree is skewed.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the space complexity of a recursive depth-first traversal of a binary tree?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
The space complexity of a recursive depth-first traversal is O(n) due to the call stack.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the space complexity of a recursive function that uses a linked list to store n elements?
A.
O(1)
B.
O(n)
C.
O(n^2)
D.
O(log n)
Show solution
Solution
The space complexity is O(n) due to the storage of n elements in the linked list.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the space complexity of a recursive function that uses a stack for function calls?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
The space complexity of a recursive function is O(n) due to the stack space used for function calls.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the space complexity of a recursive function that uses a stack to perform depth-first search on a graph?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
The space complexity is O(n) due to the maximum depth of the recursion stack in the worst case.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the space complexity of a recursive function that uses a stack to store function calls?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
The space complexity is O(n) due to the maximum depth of the recursion stack.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the space complexity of a recursive function that uses a stack?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
The space complexity of a recursive function is O(n) due to the stack space used for function calls.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the space complexity of a recursive function that uses O(n) space for its call stack?
A.
O(1)
B.
O(n)
C.
O(n^2)
D.
O(log n)
Show solution
Solution
The space complexity of a recursive function that uses O(n) space for its call stack is O(n).
Correct Answer:
B
— O(n)
Learn More →
Q. What is the space complexity of a recursive function that uses O(n) stack space?
A.
O(1)
B.
O(n)
C.
O(n^2)
D.
O(log n)
Show solution
Solution
The space complexity of a recursive function that uses O(n) stack space is O(n) due to the call stack.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the space complexity of a recursive function that uses stack space?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
The space complexity of a recursive function is O(n) due to the stack space used for each recursive call.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the space complexity of a recursive implementation of a binary tree traversal?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n log n)
Show solution
Solution
The space complexity is O(n) due to the recursion stack in the worst case, where n is the number of nodes in the tree.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the space complexity of a recursive implementation of binary tree traversal?
A.
O(n)
B.
O(log n)
C.
O(1)
D.
O(n log n)
Show solution
Solution
The space complexity is O(n) due to the recursion stack in the worst case, where n is the number of nodes in the tree.
Correct Answer:
A
— O(n)
Learn More →
Q. What is the space complexity of a recursive in-order traversal of a binary tree?
A.
O(n)
B.
O(log n)
C.
O(1)
D.
O(n log n)
Show solution
Solution
The space complexity is O(h) where h is the height of the tree, which is O(log n) for balanced trees.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the space complexity of a recursive inorder traversal of a binary tree?
A.
O(n)
B.
O(log n)
C.
O(1)
D.
O(n log n)
Show solution
Solution
The space complexity is O(h), where h is the height of the tree. In the worst case of a skewed tree, this can be O(n), but for a balanced tree, it is O(log n).
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the space complexity of a recursive pre-order traversal of a binary tree?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n log n)
Show solution
Solution
The space complexity is O(n) due to the recursion stack, which can go as deep as the height of the tree in the worst case.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the space complexity of a recursive preorder traversal of a binary tree?
A.
O(1)
B.
O(n)
C.
O(h)
D.
O(n log n)
Show solution
Solution
The space complexity of a recursive preorder traversal is O(h), where h is the height of the tree due to the call stack.
Correct Answer:
C
— O(h)
Learn More →
Q. What is the space complexity of a recursive traversal of a binary tree?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n log n)
Show solution
Solution
The space complexity of a recursive traversal of a binary tree is O(n) due to the call stack.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the space complexity of a typical dynamic programming solution that uses a 2D table?
A.
O(1)
B.
O(n)
C.
O(n^2)
D.
O(n log n)
Show solution
Solution
The space complexity of a typical dynamic programming solution that uses a 2D table is O(n^2), where n is the size of the input.
Correct Answer:
C
— O(n^2)
Learn More →
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)
Show solution
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 space complexity of BFS in a graph with V vertices?
A.
O(V)
B.
O(E)
C.
O(V + E)
D.
O(1)
Show solution
Solution
BFS requires O(V) space for the queue to store the vertices at the current level.
Correct Answer:
A
— O(V)
Learn More →
Q. What is the space complexity of BFS in a graph?
A.
O(V)
B.
O(E)
C.
O(V + E)
D.
O(1)
Show solution
Solution
The space complexity of BFS is O(V) due to the storage of the queue that can hold all vertices at the current level.
Correct Answer:
A
— O(V)
Learn More →
Q. What is the space complexity of BFS in the worst case?
A.
O(V)
B.
O(E)
C.
O(V + E)
D.
O(V^2)
Show solution
Solution
The space complexity of BFS in the worst case is O(V) due to the storage of the queue.
Correct Answer:
A
— O(V)
Learn More →
Q. What is the space complexity of BFS using an adjacency list representation?
A.
O(V)
B.
O(E)
C.
O(V + E)
D.
O(1)
Show solution
Solution
BFS requires space for the queue and visited list, leading to a space complexity of O(V) for the vertices.
Correct Answer:
A
— O(V)
Learn More →
Q. What is the space complexity of BFS?
A.
O(V)
B.
O(E)
C.
O(V + E)
D.
O(V^2)
Show solution
Solution
The space complexity of BFS is O(V) due to the storage of the queue that holds all vertices at the current level.
Correct Answer:
A
— O(V)
Learn More →
Q. What is the space complexity of binary search when implemented iteratively?
A.
O(n)
B.
O(log n)
C.
O(1)
D.
O(n log n)
Show solution
Solution
The space complexity of iterative binary search is O(1) since it uses a constant amount of space regardless of the input size.
Correct Answer:
C
— O(1)
Learn More →
Q. What is the space complexity of binary search?
A.
O(n)
B.
O(log n)
C.
O(1)
D.
O(n log n)
Show solution
Solution
Binary search has a space complexity of O(1) when implemented iteratively.
Correct Answer:
C
— O(1)
Learn More →
Q. What is the space complexity of Depth-First Search (DFS) in the worst case?
A.
O(V)
B.
O(E)
C.
O(V + E)
D.
O(log V)
Show solution
Solution
The space complexity of DFS in the worst case is O(V) due to the stack space used for recursion or the explicit stack.
Correct Answer:
A
— O(V)
Learn More →
Q. What is the space complexity of Depth-First Search (DFS) using recursion?
A.
O(V)
B.
O(E)
C.
O(V + E)
D.
O(1)
Show solution
Solution
The space complexity of DFS using recursion is O(V) due to the call stack that can go as deep as the number of vertices in the worst case.
Correct Answer:
A
— O(V)
Learn More →
Q. What is the space complexity of DFS in the worst case?
A.
O(V)
B.
O(E)
C.
O(V + E)
D.
O(V^2)
Show solution
Solution
The space complexity of DFS in the worst case is O(V) due to the stack used for recursion or explicit stack storage.
Correct Answer:
A
— O(V)
Learn More →
Q. What is the space complexity of DFS using a recursive approach?
A.
O(V)
B.
O(E)
C.
O(V + E)
D.
O(1)
Show solution
Solution
The space complexity of DFS using recursion is O(V) due to the call stack used for recursion.
Correct Answer:
A
— O(V)
Learn More →
Showing 1711 to 1740 of 3237 (108 Pages)