Q. What is the time complexity for deleting a node in an AVL tree?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
The time complexity for deleting a node in an AVL tree is O(log n) as the tree remains balanced after deletion.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity for deleting an element from a Red-Black tree?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
The time complexity for deleting an element 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 for deleting an element from an AVL tree?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
Deleting an element from an AVL tree also takes O(log n) time, as it may require rebalancing.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity for searching an element in a balanced AVL tree?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
The time complexity for searching an element in a balanced AVL tree is O(log n) due to its balanced nature.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity for searching an element in a Red-Black tree?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
Searching for an element in a Red-Black tree takes O(log n) time due to its balanced nature.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity for searching an element in an AVL tree?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
The time complexity for searching an element in an AVL tree is O(log n) due to its balanced nature.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity of a binary search algorithm on a sorted array?
-
A.
O(1)
-
B.
O(log n)
-
C.
O(n)
-
D.
O(n log n)
Solution
The time complexity of binary search on a sorted array is O(log n) because it repeatedly divides the search interval in half.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity of a binary search on a sorted array?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
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 a breadth-first search (BFS) in a graph?
-
A.
O(V)
-
B.
O(E)
-
C.
O(V + E)
-
D.
O(V^2)
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:
C
— O(V + E)
Learn More →
Q. What is the time complexity of a breadth-first search (BFS) on a graph with V vertices and E edges?
-
A.
O(V)
-
B.
O(E)
-
C.
O(V + E)
-
D.
O(V * E)
Solution
BFS visits each vertex and edge once, leading to a time complexity of O(V + E).
Correct Answer:
C
— O(V + E)
Learn More →
Q. What is the time complexity of a breadth-first search (BFS) on a graph?
-
A.
O(V)
-
B.
O(E)
-
C.
O(V + E)
-
D.
O(V^2)
Solution
BFS visits each vertex and edge once, resulting in a time complexity of O(V + E).
Correct Answer:
C
— O(V + E)
Learn More →
Q. What is the time complexity of a bubble sort algorithm in the worst case?
-
A.
O(n)
-
B.
O(n log n)
-
C.
O(n^2)
-
D.
O(log n)
Solution
Bubble sort compares adjacent elements and requires O(n^2) time in the worst case.
Correct Answer:
C
— O(n^2)
Learn More →
Q. What is the time complexity of a depth-first search (DFS) in a graph?
-
A.
O(V)
-
B.
O(E)
-
C.
O(V + E)
-
D.
O(V^2)
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 a depth-first search (DFS) on a graph with V vertices and E edges?
-
A.
O(V + E)
-
B.
O(V)
-
C.
O(E)
-
D.
O(V^2)
Solution
DFS visits each vertex and edge once, leading to a time complexity of O(V + E).
Correct Answer:
A
— O(V + E)
Learn More →
Q. What is the time complexity of a depth-first search (DFS) on a graph?
-
A.
O(V)
-
B.
O(E)
-
C.
O(V + E)
-
D.
O(V * E)
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 a depth-first search (DFS) on a tree?
-
A.
O(V)
-
B.
O(E)
-
C.
O(V + E)
-
D.
O(n log n)
Solution
DFS visits each vertex once, resulting in a time complexity of O(V) for trees.
Correct Answer:
A
— O(V)
Learn More →
Q. What is the time complexity of a level order traversal of a binary tree?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(1)
Solution
Level order traversal visits each node exactly once, resulting in a time complexity of O(n), where n is the number of nodes in the tree.
Correct Answer:
A
— O(n)
Learn More →
Q. What is the time complexity of a linear search algorithm?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n^2)
Solution
Linear search checks each element one by one, resulting in a time complexity of O(n).
Correct Answer:
B
— O(n)
Learn More →
Q. What is the time complexity of a linear search in an array?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n log n)
Solution
Linear search checks each element one by one, resulting in a time complexity of O(n).
Correct Answer:
B
— O(n)
Learn More →
Q. What is the time complexity of a linear search in an unsorted array?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n log n)
Solution
A linear search requires checking each element, leading to a time complexity of O(n).
Correct Answer:
B
— O(n)
Learn More →
Q. What is the time complexity of a queue's enqueue operation in a linked list implementation?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n log n)
Solution
The enqueue operation in a linked list implementation of a queue has a time complexity of O(1) because it adds an element to the end of the list.
Correct Answer:
A
— O(1)
Learn More →
Q. What is the time complexity of a queue's enqueue operation using a linked list?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n log n)
Solution
Enqueuing an element at the end of a linked list can be done in constant time, O(1).
Correct Answer:
A
— O(1)
Learn More →
Q. What is the time complexity of a queue's enqueue operation?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n^2)
Solution
Enqueue operation 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 a recursive function that divides the problem size by half at each step?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(n log n)
-
D.
O(2^n)
Solution
The time complexity is O(log n) because the problem size is halved at each recursive call.
Correct Answer:
B
— O(log n)
Learn More →
Q. What is the time complexity of accessing an element in a linked list by index?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n log n)
Solution
Accessing an element in a linked list by index is O(n) because it requires traversing the list from the head to the desired index.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the time complexity of accessing an element in a queue implemented using a linked list?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n^2)
Solution
Accessing an element in a queue implemented using a linked list requires traversing the list, resulting in a time complexity of O(n).
Correct Answer:
B
— O(n)
Learn More →
Q. What is the time complexity of accessing an element in a queue?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n^2)
Solution
Accessing an element in a queue typically requires O(n) time because you may need to traverse the queue to find the element.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the time complexity of accessing an element in a stack?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(1)
-
D.
O(n log n)
Solution
Accessing the top element of a stack is a constant time operation, hence O(1).
Correct Answer:
C
— O(1)
Learn More →
Q. What is the time complexity of accessing an element in an array by index?
-
A.
O(n)
-
B.
O(log n)
-
C.
O(1)
-
D.
O(n log n)
Solution
Accessing an element in an array by index is O(1) because it requires a constant amount of time regardless of the size of the array.
Correct Answer:
C
— O(1)
Learn More →
Q. What is the time complexity of accessing an element in an array?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n^2)
Solution
Accessing an element in an array by index is done in constant time, O(1).
Correct Answer:
A
— O(1)
Learn More →
Showing 1771 to 1800 of 3237 (108 Pages)