Stack/Queue Applications

Download Q&A
Q. In a stack, what is the result of the operation 'push(5)', followed by 'push(10)', and then 'pop()'?
  • A. 5
  • B. 10
  • C. Both 5 and 10
  • D. Stack is empty
Q. In which scenario would you prefer using a stack over a queue?
  • A. When you need to process tasks in the order they arrive
  • B. When you need to backtrack through a series of operations
  • C. When you need to manage tasks with priority
  • D. When you need to store data persistently
Q. What happens when you try to pop an element from an empty stack?
  • A. It returns null
  • B. It throws an exception
  • C. It returns the last element added
  • D. It does nothing
Q. What is the main difference between a stack and a queue?
  • A. Stack is LIFO, Queue is FIFO
  • B. Stack is FIFO, Queue is LIFO
  • C. Both are LIFO
  • D. Both are FIFO
Q. Which of the following is a common application of a queue?
  • A. Function call management
  • B. Undo functionality in text editors
  • C. Breadth-first search in graphs
  • D. Expression evaluation
Q. Which of the following operations can be performed in constant time on a queue?
  • A. Enqueue
  • B. Dequeue
  • C. Peek
  • D. All of the above
Q. Which of the following operations is NOT typically associated with a queue?
  • A. Enqueue
  • B. Dequeue
  • C. Peek
  • D. Push
Showing 1 to 7 of 7 (1 Pages)
Soulshift Feedback ×

On a scale of 0–10, how likely are you to recommend The Soulshift Academy?

Not likely Very likely