Q. What is the time complexity of deleting an element from a linked list when the pointer to the node is given?
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 →
Q. What is the time complexity of deleting an element 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, the deletion can be done 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?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
The time complexity is O(n) in the worst case, as you may need to traverse the list to find the element to delete.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the time complexity of deleting an element from a queue implemented using a linked list?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
Deleting an element from the front of a queue implemented with a linked list is done in constant time, O(1).
Correct Answer:
A
— O(1)
Learn More →
Q. What is the time complexity of deleting an element from a queue implemented with a linked list?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n log n)
Show solution
Solution
Deleting from the front of a linked list queue is a constant time operation, hence O(1).
Correct Answer:
A
— O(1)
Learn More →
Q. What is the time complexity of deleting an element from a queue?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
Deleting an element from the front of a queue is done in constant time, hence O(1).
Correct Answer:
A
— O(1)
Learn More →
Q. What is the time complexity of deleting an element from a singly linked list when the pointer to the node is given?
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 can be done in O(1) time.
Correct Answer:
A
— O(1)
Learn More →
Q. What is the time complexity of deleting an element from a stack?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
Deleting an element from a stack (pop operation) is done in constant time, hence O(1).
Correct Answer:
A
— O(1)
Learn More →
Q. What is the time complexity of deleting the last element from a dynamic array?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
Deleting the last element from a dynamic array is a constant time operation, so the time complexity is O(1).
Correct Answer:
A
— O(1)
Learn More →
Q. What is the time complexity of deleting the last element from a singly linked list?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
To delete the last element from a singly linked list, you must traverse the list to find the second-to-last element, resulting in O(n) time complexity.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the time complexity of deleting the last node in a singly linked list?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n log n)
Show solution
Solution
To delete the last node in a singly linked list, you must traverse the list to find the second-to-last node, resulting in O(n) time complexity.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the time complexity of depth-first search (DFS) in a graph?
A.
O(V)
B.
O(E)
C.
O(V + E)
D.
O(V^2)
Show solution
Solution
DFS 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:
C
— O(V + E)
Learn More →
Q. What is the time complexity of depth-first search (DFS) on a graph?
A.
O(V)
B.
O(E)
C.
O(V + E)
D.
O(V * E)
Show solution
Solution
DFS explores all vertices (V) and edges (E) in the graph, leading to a time complexity of O(V + E).
Correct Answer:
C
— O(V + E)
Learn More →
Q. What is the time complexity of dequeuing an element from a queue implemented using a circular array?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
Dequeuing an element from a queue implemented using a circular array can be done in constant time, O(1), as it involves adjusting the front index.
Correct Answer:
A
— O(1)
Learn More →
Q. What is the time complexity of dequeuing an element from a queue implemented using a linked list?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n log n)
Show solution
Solution
Dequeuing from a queue implemented with a linked list is O(1) as it involves removing the head node.
Correct Answer:
A
— O(1)
Learn More →
Q. What is the time complexity of dequeuing an element from a queue implemented using an array?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
Dequeuing an element from a queue implemented using an array can take O(n) time if all elements need to be shifted after removing the front element.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the time complexity of Dijkstra's algorithm using a binary heap?
A.
O(V^2)
B.
O(E log V)
C.
O(V log V)
D.
O(E + V)
Show solution
Solution
The time complexity of Dijkstra's algorithm using a binary heap is O(E log V), where E is the number of edges and V is the number of vertices.
Correct Answer:
B
— O(E log V)
Learn More →
Q. What is the time complexity of Dijkstra's algorithm using a priority queue implemented with a binary heap?
A.
O(V^2)
B.
O(E log V)
C.
O(V log V)
D.
O(E + V)
Show solution
Solution
Dijkstra's algorithm has a time complexity of O(E log V) when using a priority queue implemented with a binary heap, where E is the number of edges and V is the number of vertices.
Correct Answer:
B
— O(E log V)
Learn More →
Q. What is the time complexity of Dijkstra's algorithm using a priority queue?
A.
O(V^2)
B.
O(E + V log V)
C.
O(V log V)
D.
O(E log V)
Show solution
Solution
Dijkstra's algorithm has a time complexity of O(E log V) when implemented with a priority queue.
Correct Answer:
D
— O(E log V)
Learn More →
Q. What is the time complexity of Dijkstra's algorithm when implemented with a binary heap?
A.
O(V^2)
B.
O(E log V)
C.
O(V log V)
D.
O(E + V)
Show solution
Solution
When using a binary heap, the time complexity of Dijkstra's algorithm is O(E log V), where E is the number of edges and V is the number of vertices.
Correct Answer:
B
— O(E log V)
Learn More →
Q. What is the time complexity of Dijkstra's algorithm when using a binary heap?
A.
O(V^2)
B.
O(E log V)
C.
O(V log V)
D.
O(E + V)
Show solution
Solution
When implemented with a binary heap, the time complexity of Dijkstra's algorithm is O(E log V), where E is the number of edges and V is the number of vertices.
Correct Answer:
B
— O(E log V)
Learn More →
Q. What is the time complexity of Dijkstra's algorithm when using a priority queue implemented with a binary heap?
A.
O(V^2)
B.
O(E log V)
C.
O(V log V)
D.
O(E + V)
Show solution
Solution
The time complexity of Dijkstra's algorithm using a binary heap is O(E log V), where E is the number of edges and V is the number of vertices.
Correct Answer:
B
— O(E log V)
Learn More →
Q. What is the time complexity of enqueue and dequeue operations in a queue implemented using a linked list?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n log n)
Show solution
Solution
Both enqueue and dequeue operations can be performed in constant time O(1) in a linked list implementation.
Correct Answer:
A
— O(1)
Learn More →
Q. What is the time complexity of enqueue and dequeue operations in a queue implemented with a linked list?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n log n)
Show solution
Solution
Both enqueue and dequeue operations can be performed in constant time, O(1), when using a linked list.
Correct Answer:
A
— O(1)
Learn More →
Q. What is the time complexity of enqueue and dequeue operations in a standard queue implemented using a linked list?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n log n)
Show solution
Solution
Both enqueue and dequeue operations in a queue implemented using a linked list have a time complexity of O(1).
Correct Answer:
A
— O(1)
Learn More →
Q. What is the time complexity of enqueueing an element in a queue implemented using an array?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
Enqueueing an element in a queue implemented using an array can be done in constant time, O(1), if there is space available.
Correct Answer:
A
— O(1)
Learn More →
Q. What is the time complexity of enqueueing an element in a queue implemented using a linked list?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n log n)
Show solution
Solution
Enqueueing an element in a queue implemented with a linked list is done in constant time, O(1), as it involves adding to the tail of the list.
Correct Answer:
A
— O(1)
Learn More →
Q. What is the time complexity of enqueueing an element in a queue implemented with a linked list?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n log n)
Show solution
Solution
Enqueueing an element in a queue implemented with a linked list is done in constant time, O(1), by adding the element to the end of the list.
Correct Answer:
A
— O(1)
Learn More →
Q. What is the time complexity of enqueueing an element in a queue?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
Enqueueing an element in a queue is done in constant time, hence O(1).
Correct Answer:
A
— O(1)
Learn More →
Q. What is the time complexity of enqueuing an element in a queue implemented using an array?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Show solution
Solution
Enqueuing an element in a queue implemented using an array is done in constant time, O(1), unless the array needs to be resized.
Correct Answer:
A
— O(1)
Learn More →
Showing 1831 to 1860 of 3237 (108 Pages)