Elementary Data Structures – stacks, queues, dequeue Quiz - ICSE Class 11 Computer Science
Free practice quiz: Elementary Data Structures – stacks, queues, dequeue (ICSE Class 11 Computer Science). 56 multiple-choice questions with answers and explanations. Play online, no sign-up needed.
Play all 56 questions freeSample questions
Consider a stack where elements are pushed and popped. If elements 1, 2, 3, 4, and 5 are pushed in that order, what will be the order of elements when popped?
- 1, 2, 3, 4, 5
- 5, 4, 3, 2, 1
- 1, 5, 2, 4, 3
- 5, 1, 4, 2, 3
Show answer
Answer: B. 5, 4, 3, 2, 1
A stack follows the Last-In, First-Out (LIFO) principle. The last element pushed (5) is the first one to be popped.
In a queue, which end is used for deletion?
- Front end
- Rear end
- Both ends
- Middle
Show answer
Answer: A. Front end
Queues follow the First-In, First-Out (FIFO) principle. Elements are deleted from the front (where the oldest element is) and inserted at the rear.
What is the purpose of the `peek` operation in a queue?
- To remove the element from the front.
- To add an element to the rear.
- To view the element at the front without removing it.
- To check if the queue is empty.
Show answer
Answer: C. To view the element at the front without removing it.
Similar to a stack's peek, a queue's peek operation allows inspection of the front element (the next to be dequeued) without altering the queue's state.
Consider the expression `(a + b) * (c - d)`. If this is converted to postfix notation, which operator will appear last?
- +
- *
- -
- d
Show answer
Answer: B. *
The expression is `(a + b) * (c - d)`. In postfix notation, this becomes `a b + c d - *`. The operators are processed based on precedence and parentheses. The outermost operation is the multiplication between the results of `(a + b)` and `(c - d)`. Therefore, '*' is the last operator to be evaluated and appears last in the postfix string.
Consider the following operations on a deque: `push_front(1)`, `push_back(2)`, `push_front(3)`, `pop_front()`. What is the final state of the deque from front to rear?
- 3, 1, 2
- 1, 2
- 3, 2
- 1, 3, 2
Show answer
Answer: B. 1, 2
Initial: [] `push_front(1)`: [1] `push_back(2)`: [1, 2] `push_front(3)`: [3, 1, 2] `pop_front()`: Removes 3. Deque: [1, 2] The final state from front to rear is [1, 2].
More quizzes
- Numbers – Number systems, base conversion, arithmetic in bases
- Packages – user-defined packages, imports, interaction
- Propositional Logic – WFF, truth tables, logic gates, adder circuits
- Software – System vs application software, OS overview
- Computer Hardware – System architecture, processor, memory types