Q. What is the time complexity of accessing the top element of a stack?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
Accessing the top element of a stack is done in constant time, hence O(1).
Correct Answer:
A
— O(1)
Learn More →
Q. What is the time complexity of an in-order traversal of a binary tree?
A.
O(n)
B.
O(log n)
C.
O(n log n)
D.
O(1)
Show solution
Solution
In-order traversal visits each node exactly once, resulting in a time complexity of O(n).
Correct Answer:
A
— 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)
Show solution
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 balancing an AVL tree after a deletion?
A.
O(n)
B.
O(log n)
C.
O(n log n)
D.
O(1)
Show solution
Solution
Balancing an AVL tree after a deletion operation takes O(log n) time.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity of balancing an AVL tree after an insertion?
A.
O(log n)
B.
O(n)
C.
O(1)
D.
O(n log n)
Show solution
Solution
Balancing an AVL tree after an insertion takes O(log n) time due to the height of the tree.
Correct Answer:
A
— O(log n)
Learn More →
Q. What is the time complexity of BFS in a graph with V vertices and E edges?
A.
O(V + E)
B.
O(V^2)
C.
O(E log V)
D.
O(V log V)
Show solution
Solution
The time complexity of BFS is O(V + E), where V is the number of vertices and E is the number of edges in the graph.
Correct Answer:
A
— O(V + E)
Learn More →
Q. What is the time complexity of BFS in terms of the number of vertices V and edges E?
A.
O(V + E)
B.
O(V^2)
C.
O(E log V)
D.
O(V log V)
Show solution
Solution
The time complexity of BFS is O(V + E) because it visits each vertex and edge once.
Correct Answer:
A
— O(V + E)
Learn More →
Q. What is the time complexity of binary search in a sorted array?
A.
O(n)
B.
O(log n)
C.
O(n log n)
D.
O(1)
Show solution
Solution
Binary search has a time complexity of O(log n) because it divides the search interval in half with each step.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity of binary search in the average case?
A.
O(1)
B.
O(log n)
C.
O(n)
D.
O(n log n)
Show solution
Solution
In the average case, binary search divides the search space in half with each iteration, leading to a time complexity of O(log n).
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity of binary search in the best case scenario?
A.
O(1)
B.
O(log n)
C.
O(n)
D.
O(n log n)
Show solution
Solution
In the best case, the target element is found at the middle of the array, resulting in a time complexity of O(1).
Correct Answer:
A
— O(1)
Learn More →
Q. What is the time complexity of binary search in the worst case scenario?
A.
O(1)
B.
O(log n)
C.
O(n)
D.
O(n log n)
Show solution
Solution
In the worst case, binary search will continue to halve the search space until it finds the target or concludes it is not present, resulting in O(log n) time complexity.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity of binary search on a sorted array?
A.
O(n)
B.
O(log n)
C.
O(n log n)
D.
O(1)
Show solution
Solution
Binary search divides the array in half with each step, leading to a time complexity of O(log n).
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity of binary search?
A.
O(n)
B.
O(log n)
C.
O(n log n)
D.
O(1)
Show solution
Solution
The time complexity of binary search is O(log n) because it divides the search interval in half with each step.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity of Breadth-First Search (BFS) in a graph with V vertices and E edges?
A.
O(V + E)
B.
O(V)
C.
O(E)
D.
O(V * E)
Show solution
Solution
BFS explores all vertices and edges, leading to a time complexity of O(V + E).
Correct Answer:
A
— O(V + E)
Learn More →
Q. What is the time complexity of breadth-first search (BFS) in a graph?
A.
O(V + E)
B.
O(V)
C.
O(E)
D.
O(V^2)
Show solution
Solution
BFS visits each vertex and edge once, leading to a time complexity of O(V + E), where V is vertices and E is edges.
Correct Answer:
A
— O(V + E)
Learn More →
Q. What is the time complexity of breadth-first search (BFS) on a graph?
A.
O(V + E)
B.
O(V)
C.
O(E)
D.
O(V^2)
Show solution
Solution
BFS visits each vertex and edge once, leading to a time complexity of O(V + E), where V is vertices and E is edges.
Correct Answer:
A
— O(V + E)
Learn More →
Q. What is the time complexity of bubble sort in the average case?
A.
O(n)
B.
O(n log n)
C.
O(n^2)
D.
O(log n)
Show solution
Solution
Bubble sort has an average case time complexity of O(n^2) due to the nested loops.
Correct Answer:
C
— O(n^2)
Learn More →
Q. What is the time complexity of bubble sort in the worst case?
A.
O(n)
B.
O(n log n)
C.
O(n^2)
D.
O(log n)
Show solution
Solution
Bubble sort has a worst-case time complexity of O(n^2) due to the nested loops.
Correct Answer:
C
— O(n^2)
Learn More →
Q. What is the time complexity of checking if a stack is empty?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
Checking if a stack is empty is done in constant time, O(1), by checking if the size is zero.
Correct Answer:
A
— O(1)
Learn More →
Q. What is the time complexity of clearing all elements from a queue?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
Clearing all elements from a queue takes O(n) time, as each element must be removed individually.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the time complexity of clearing all elements from a stack?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
Clearing all elements from a stack requires popping each element, leading to a time complexity of O(n).
Correct Answer:
B
— O(n)
Learn More →
Q. What is the time complexity of deleting a node from a binary search tree in the average case?
A.
O(n)
B.
O(log n)
C.
O(n log n)
D.
O(1)
Show solution
Solution
In the average case, deleting a node from a balanced binary search tree has a time complexity of O(log n).
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity of deleting a node from a linked list when you have a pointer to that node?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
If you have a pointer to the node to be deleted, you can delete it in constant time O(1) by adjusting pointers.
Correct Answer:
A
— O(1)
Learn More →
Q. What is the time complexity of deleting a node from a Red-Black tree?
A.
O(n)
B.
O(log n)
C.
O(n log n)
D.
O(1)
Show solution
Solution
The time complexity for deleting a node from a Red-Black tree is O(log n) due to its balanced structure.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity of deleting a node from a singly linked list given a pointer to that node?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n log n)
Show solution
Solution
If you have a pointer to the node to be deleted, you can delete it in O(1) time by copying the next node's data.
Correct Answer:
A
— O(1)
Learn More →
Q. What is the time complexity of deleting a node from an AVL tree?
A.
O(n)
B.
O(log n)
C.
O(n log n)
D.
O(1)
Show solution
Solution
The time complexity of deleting a node from an AVL tree is O(log n) due to its balanced structure.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity of deleting a node in a Red-Black tree?
A.
O(log n)
B.
O(n)
C.
O(n log n)
D.
O(1)
Show solution
Solution
The time complexity of deleting a node in a Red-Black tree is O(log n) due to the balancing operations.
Correct Answer:
A
— O(log n)
Learn More →
Q. What is the time complexity of deleting an element from a binary search tree (BST) in the average case?
A.
O(n)
B.
O(log n)
C.
O(n log n)
D.
O(1)
Show solution
Solution
In the average case, deleting an element from a balanced binary search tree takes O(log n) time, as it requires finding the element and then restructuring the tree.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity of deleting an element from a doubly linked list?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
If you have a pointer to the node to be deleted, the deletion operation can be performed in constant time, O(1).
Correct Answer:
A
— O(1)
Learn More →
Q. What is the time complexity of deleting an element from a linked list given a pointer to that node?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n log n)
Show solution
Solution
If you have a pointer to the node to be deleted, the deletion can be done in constant time, O(1).
Correct Answer:
A
— O(1)
Learn More →
Showing 1801 to 1830 of 3237 (108 Pages)