Data Structures u0026 Algorithms: Stacks, Queues, and Their Applications Quiz

Test your understanding of stacks, queues, monotonic stacks, sliding window maximum, circular queues, and deque implementations with these beginner-friendly questions.

  1. Stack Implementation: Array or Linked List

    Which operation removes the top element from a stack implemented using an array?

    1. insertFront
    2. enqueue
    3. peek
    4. pop
    5. copy
  2. Basic Queue Operation

    What is the term for adding an element to the rear of a queue, for example adding '5' to [2, 3, 4] producing [2, 3, 4, 5]?

    1. pop
    2. insertLast
    3. enqueue
    4. emit
    5. push
  3. Monotonic Stack Usage

    Monotonic stacks are most often used to efficiently solve which type of problem from a sequence, such as finding the next greater element for each item?

    1. Counting sort
    2. Span problems
    3. Binary search
    4. Sorting arrays
    5. Minimum sum subarray
  4. Deque Basic Concept

    What distinguishes a deque (double-ended queue) from a regular queue, when implemented using an array?

    1. It only pops from the rear
    2. Elements can be added or removed at both ends
    3. It only allows push operations
    4. It strictly follows LIFO order
    5. It can't store duplicate values
  5. Sliding Window Maximum Principle

    In the sliding window maximum problem, what is the main goal when given an array and a window size k?

    1. Compute the sum of all elements
    2. Find the maximum in each subarray of length k
    3. Find the minimum in the entire array
    4. Sort the entire array
    5. Count the number of zeros
  6. Linked List Stack Operations

    When implementing a stack using a singly linked list, where should the top pointer move after a pop operation?

    1. To the array end
    2. To index zero always
    3. To the next node
    4. To the previous node
    5. To the last node
  7. Circular Queue Wraparound

    In a circular queue implemented with an array, what happens when the rear index moves past the last position?

    1. It jumps to the middle of the array
    2. It wraps around to the first index
    3. It pushes the first element out
    4. It throws an exception by default
    5. It goes to null
  8. Stack Top Element

    Which operation returns the element at the top of the stack without removing it, for example, returning '8' from [3, 8, 1]?

    1. enqueue
    2. insertFront
    3. copyTop
    4. delete
    5. peek
  9. Queue FIFO Principle

    Which data structure always removes elements in the same order as they were added, such as [5, 6, 7] outputting 5 first?

    1. Deque
    2. Heap
    3. Tree
    4. Stack
    5. Queue
  10. Deque Use Case

    Which real-world scenario best fits a deque, for example, managing both arrivals and departures in a two-way street?

    1. Sum of array elements calculation
    2. Counting occurrences of a value
    3. Reversing a sorted array
    4. Managing task scheduling where tasks can be added or processed from both front and rear
    5. Last-in first-out retrieval like browser back button