1.What is a stack in the context of data structures?

A) A linear data structure

B) A hierarchical data structure

C) A non-linear data structure

D) A matrix data structure

Answer: A) A linear data structure

Explanation: Stacks are linear data structures that follow the Last In, First Out (LIFO) principle.

2.Which of the following operations is NOT typically associated with a stack?

A) Push

B) Pop

C) Peek

D) Delete

Answer: D) Delete

Explanation: Stacks typically support push (adding an element), pop (removing the top element), and peek (viewing the top element) operations.

3.Which implementation of a stack utilizes arrays?

A) Linked list

B) Array

C) Hash table

D) Binary tree

Answer: B) Array

Explanation: Stacks can be implemented using arrays or linked lists. Array-based implementation offers constant time access to elements.

4.In a stack, where is the new element added during the push operation?

A) At the top

B) At the bottom

C) In the middle

D) Randomly

Answer: A) At the top

Explanation: The push operation adds elements to the top of the stack.

5.Which application often involves converting infix expressions to postfix using stacks?

A) Sorting

B) Searching

C) Parsing

D) Compression

Answer: C) Parsing

Explanation: Converting infix expressions to postfix is a common step in parsing mathematical expressions.

6.What is the result of evaluating a postfix expression?

A) Infix expression

B) Prefix expression

C) Value

D) Variable

Answer: C) Value

Explanation: Postfix expressions are evaluated to obtain a value.

7.Which recursion principle resembles the operation of a stack?

A) Top-down recursion

B) Tail recursion

C) Bottom-up recursion

D) Divide and conquer recursion

Answer: B) Tail recursion

Explanation: Tail recursion is similar to using a stack where recursive calls are made as the last operation.

8.What is a queue in the context of data structures?

A) A linear data structure

B) A hierarchical data structure

C) A non-linear data structure

D) A matrix data structure

Answer: A) A linear data structure

Explanation: Queues are linear data structures that follow the First In, First Out (FIFO) principle.

9.Which operation in a queue removes an element from the front?

A) Push

B) Pop

C) Enqueue

D) Dequeue

Answer: D) Dequeue

Explanation: Dequeue operation removes an element from the front of the queue.

10.Which implementation of a queue is specifically designed to handle overflow conditions?

A) Circular queue

B) Priority queue

C) Linked list

D) Array

Answer: A) Circular queue

Explanation: Circular queues wrap around when reaching the end, allowing efficient use of space and handling overflow conditions.

11.What is a double-ended queue (Dqueue)?

A) A queue with double the capacity

B) A queue that supports insertion and deletion at both ends

C) A queue with two separate queues

D) A queue that prioritizes elements based on their value

Answer: B) A queue that supports insertion and deletion at both ends

Explanation: A double-ended queue supports insertion and deletion at both the front and rear ends.

12.Which of the following is NOT a characteristic of a priority queue?

A) Elements are removed based on their priority.

B) Elements are inserted based on their priority.

C) Priority is determined by the order of insertion.

D) It can be implemented using heaps.

Answer: C) Priority is determined by the order of insertion.

Explanation: Priority in a priority queue is determined by the priority of elements, not the order of insertion.

13.Which implementation of a queue allows simulation of real-world scenarios like waiting lines?

A) Linked list

B) Array

C) Priority queue

D) Circular queue

Answer: D) Circular queue

Explanation: Circular queues are suitable for simulating scenarios like waiting lines where elements join and leave the queue.

14.Which application often involves simulation using queues?

A) Sorting algorithms

B) Graph traversal

C) Process scheduling

D) Data compression

Answer: C) Process scheduling

Explanation: Queues are commonly used in process scheduling algorithms to manage tasks.

15.What is the primary difference between stacks and queues?

A) Stacks follow FIFO, while queues follow LIFO.

B) Stacks allow insertion and deletion at both ends, while queues allow only at one end.

C) Stacks follow LIFO, while queues follow FIFO.

D) Stacks have a fixed size, while queues can dynamically resize.

Answer: C) Stacks follow LIFO, while queues follow FIFO.

Explanation: Stacks operate on Last In, First Out principle, while queues operate on First In, First Out principle.

16.Which data structure would be most suitable for implementing undo functionality in a text editor?

A) Stack

B) Queue

C) Priority queue

D) Linked list

Answer: A) Stack

Explanation: Undo functionality requires the last action to be undone first, which aligns with the LIFO property of stacks.

17.Which operation in a stack retrieves the top element without removing it?

A) Peek

B) Pop

C) Push

D) Search

Answer: A) Peek

Explanation: Peek operation returns the value of the top element without removing it from the stack.

18.In a circular queue, what happens when the rear pointer reaches the end of the queue?

A) The rear pointer stops, and further insertions are not possible.

B) The rear pointer wraps around to the beginning of the queue.

C) The rear pointer becomes NULL.

D) The rear pointer moves to the next position.

Answer: B) The rear pointer wraps around to the beginning of the queue.

Explanation: Circular queues wrap around when the rear pointer reaches the end, allowing continuous insertion.

19.Which operation in a priority queue is used to retrieve the element with the highest priority?

A) Enqueue

B) Dequeue

C) Peek

D) Pop

Answer: C) Peek

Explanation: Peek operation retrieves the element with the highest priority without removing it.

20.Which of the following data structures is NOT typically implemented using stacks or queues?

A) Binary tree

B) Graph

C) Hash table

D) Heap

Answer: C) Hash table

Explanation: While binary trees, graphs, and heaps can be implemented using stacks or queues, hash tables are typically implemented differently, using arrays or linked lists with hash functions.