Q. In which application would you use a stack to evaluate expressions?
A.
Infix to postfix conversion
B.
Sorting a list of numbers
C.
Searching for an element
D.
Implementing a binary tree
Show solution
Solution
Stacks are used in infix to postfix conversion to hold operators and operands while evaluating expressions.
Correct Answer:
A
— Infix to postfix conversion
Learn More →
Q. What is a common application of stacks in programming?
A.
Managing function calls
B.
Storing data in a sorted manner
C.
Implementing a priority queue
D.
Searching for elements in a list
Show solution
Solution
Stacks are commonly used to manage function calls in programming languages, where each function call is pushed onto the stack and popped off when it returns.
Correct Answer:
A
— Managing function calls
Learn More →
Q. What is a typical use case for a circular queue?
A.
Implementing a stack
B.
Handling requests in a round-robin manner
C.
Sorting elements
D.
Searching for an element
Show solution
Solution
Circular queues are often used to handle requests in a round-robin manner, allowing for efficient use of space and time.
Correct Answer:
B
— Handling requests in a round-robin manner
Learn More →
Q. What is the primary advantage of using a deque (double-ended queue)?
A.
Faster sorting
B.
Access to both ends for insertion and deletion
C.
Lower memory usage
D.
Easier implementation
Show solution
Solution
The primary advantage of a deque is that it allows insertion and deletion from both ends, making it more flexible than a standard queue.
Correct Answer:
B
— Access to both ends for insertion and deletion
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. Which data structure would you use to implement a backtracking algorithm?
A.
Queue
B.
Stack
C.
Linked List
D.
Array
Show solution
Solution
A stack is used in backtracking algorithms to keep track of the previous states and to backtrack when necessary.
Correct Answer:
B
— Stack
Learn More →
Q. Which of the following is an application of queues?
A.
Undo functionality in text editors
B.
Breadth-first search in graphs
C.
Expression evaluation
D.
Memory management
Show solution
Solution
Queues are used in breadth-first search algorithms for traversing graphs, as they follow the FIFO (First In, First Out) principle.
Correct Answer:
B
— Breadth-first search in graphs
Learn More →
Showing 1 to 7 of 7 (1 Pages)