Q. In a queue implemented using an array, what happens when the array is full?
-
A.
Overflow error
-
B.
Underflow error
-
C.
Elements are overwritten
-
D.
Queue shrinks
Solution
When a queue implemented using an array is full, it results in an overflow error as no more elements can be added.
Correct Answer:
A
— Overflow error
Learn More →
Q. In a queue implemented using an array, what is the time complexity of enqueue operation in the worst case?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n^2)
Solution
In the worst case, if the array is full and needs to be resized, the enqueue operation can take O(n) time.
Correct Answer:
B
— O(n)
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)
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 worst-case time complexity of insertion in a linked list?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n^2)
Solution
Inserting an element in a linked list can take O(n) time in the worst case if the position is at the end and traversal is required.
Correct Answer:
B
— O(n)
Learn More →
Q. What is the worst-case time complexity of insertion in a singly linked list?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n^2)
Solution
In the worst case, you may need to traverse the entire list to find the insertion point, resulting in O(n) time complexity.
Correct Answer:
B
— O(n)
Learn More →
Q. Which data structure is used to implement recursion?
-
A.
Array
-
B.
Stack
-
C.
Queue
-
D.
Linked List
Solution
Recursion is implemented using a stack, which keeps track of function calls and local variables.
Correct Answer:
B
— Stack
Learn More →
Q. Which sorting algorithm is best suited for linked lists?
-
A.
Quick sort
-
B.
Merge sort
-
C.
Bubble sort
-
D.
Heap sort
Solution
Merge sort is best suited for linked lists as it can be implemented without additional space and works well with the linked structure.
Correct Answer:
B
— Merge sort
Learn More →
Showing 1 to 7 of 7 (1 Pages)