Q. In which real-world application would you use a queue?
-
A.
Undo functionality in text editors
-
B.
Browser history management
-
C.
Task scheduling in operating systems
-
D.
Expression evaluation
Solution
Queues are used in task scheduling in operating systems where processes are managed in a first-come, first-served manner.
Correct Answer:
C
— Task scheduling in operating systems
Learn More →
Q. In which scenario would a stack be more beneficial than a queue?
-
A.
When processing tasks in order of arrival
-
B.
When reversing a string
-
C.
When managing print jobs
-
D.
When implementing breadth-first search
Solution
A stack is more beneficial when reversing a string, as it allows for the last character added to be the first one processed.
Correct Answer:
B
— When reversing a string
Learn More →
Q. What is the time complexity of enqueuing an element in a queue implemented with a linked list?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n^2)
Solution
Enqueuing an element in a queue implemented with a linked list can be 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 popping an element from a stack?
-
A.
O(1)
-
B.
O(n)
-
C.
O(log n)
-
D.
O(n^2)
Solution
Popping an element from a stack is also done in constant time, O(1), as it involves removing the top element.
Correct Answer:
A
— O(1)
Learn More →
Showing 1 to 4 of 4 (1 Pages)