Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.
Which data structure follows the LIFO (Last In First Out) principle?
Not quite. Try another option.
Answer: Stack
A stack follows the LIFO principle, meaning the last element added is the first one to be removed.
Question 2 of 50
In a stack implemented using an array of size N, what is the condition for stack overflow?
Not quite. Try another option.
Answer: top == N - 1
In a 0-indexed array, the last index is N-1. If the top pointer reaches N-1, no more elements can be pushed, indicating an overflow.
Question 3 of 50
What is the time complexity of the push operation in a stack implemented using an array?
Not quite. Try another option.
Answer: O(1)
Pushing onto a stack involves incrementing the top pointer and assigning a value, which takes constant time O(1).
Question 4 of 50
Which operation removes the top element from the stack?
Not quite. Try another option.
Answer: Pop
The Pop operation removes the element currently at the top of the stack and decrements the top pointer.
Question 5 of 50
In a linked list representation of a stack, where are elements pushed and popped from?
Not quite. Try another option.
Answer: The head of the list
Inserting and deleting from the head of a linked list is O(1), making it the most efficient end to represent the top of the stack.
Question 6 of 50
What happens if you try to pop an element from an empty stack?
Not quite. Try another option.
Answer: Stack Underflow
Stack Underflow occurs when an attempt is made to remove an item from a stack that contains no elements.
Question 7 of 50
Which pointer is used to track the last element added to a stack?
Not quite. Try another option.
Answer: Top
The 'Top' pointer always points to the most recently added element in the stack.
Question 8 of 50
What is the result of evaluating the postfix expression: 5 3 + 2 * ?
Not quite. Try another option.
Answer: 16
5 + 3 = 8. Then 8 * 2 = 16.
Question 9 of 50
Another name for Reverse Polish Notation (RPN) is:
Not quite. Try another option.
Answer: Postfix Notation
Reverse Polish Notation places operators after their operands, which is the definition of Postfix Notation.
Question 10 of 50
Convert the infix expression (A + B) * C into postfix.
Not quite. Try another option.
Answer: A B + C *
The parentheses force A+B to be evaluated first (AB+), followed by multiplication with C (AB+C*).
Question 11 of 50
Which data structure is primarily used to convert infix expressions to postfix expressions?
Not quite. Try another option.
Answer: Stack
A stack is used to hold operators and manage their precedence during the conversion from infix to postfix.
Question 12 of 50
In Polish notation (Prefix), where is the operator placed?
Not quite. Try another option.
Answer: Before the operands
In Prefix (Polish) notation, the operator precedes the operands (e.g., +AB).
Question 13 of 50
What is the prefix form of the expression: A + B * C ?
Not quite. Try another option.
Answer: + A * B C
Multiplication has higher precedence: BC becomes BC. Then addition: + A (*BC).
Question 14 of 50
When evaluating a postfix expression, what do you do when you encounter an operand?
Not quite. Try another option.
Answer: Push onto stack
Operands are pushed onto the stack. When an operator is encountered, operands are popped to perform the calculation.
Question 15 of 50
Which operator has the highest precedence among the following?
Not quite. Try another option.
Answer: ^ (Exponentiation)
Exponentiation typically has higher precedence than multiplication, division, addition, and subtraction.
Question 16 of 50
The associativity of the exponentiation operator (^) is usually:
Not quite. Try another option.
Answer: Right to Left
In most contexts, 2^3^2 is evaluated as 2^(3^2), which is Right to Left.
Question 17 of 50
Which data structure follows the FIFO (First In First Out) principle?
Not quite. Try another option.
Answer: Queue
A Queue adds elements to the rear and removes them from the front, following FIFO.
Question 18 of 50
The operation of adding an element to a queue is called:
Not quite. Try another option.
Answer: Enqueue
Enqueue is the standard term for inserting an element into a queue.
Question 19 of 50
In an array implementation of a simple queue, which pointers are maintained?
Not quite. Try another option.
Answer: Front and Rear
Front tracks the first element (for deletion), and Rear tracks the last element (for insertion).
Question 20 of 50
What is the initial value of Front and Rear in an empty queue (array implementation)?
Not quite. Try another option.
Answer: -1
Traditionally, -1 indicates that the pointers refer to no valid index in the array.
Question 21 of 50
In a linear queue array implementation, a queue is empty when:
Not quite. Try another option.
Answer: Front == -1
If Front is -1 (and usually Rear is also -1), the queue contains no elements.
Question 22 of 50
What is the major drawback of a simple linear queue implemented with an array?
Not quite. Try another option.
Answer: Empty spaces created by dequeue cannot be reused
Once Rear reaches the end of the array, no more elements can be added even if space exists at the beginning due to previous dequeues.
Question 23 of 50
Which data structure resolves the memory wastage issue of a linear queue?
Not quite. Try another option.
Answer: Circular Queue
A Circular Queue connects the end of the array back to the beginning, allowing reuse of empty spaces.
Question 24 of 50
In a Circular Queue of size N, the condition for the queue being full is:
Not quite. Try another option.
Answer: (Rear + 1) % N == Front
This formula checks if the next position after Rear wraps around to the current Front, indicating the buffer is full.
Question 25 of 50
In a linked list implementation of a queue, where is the Enqueue operation performed?
Not quite. Try another option.
Answer: At the Tail (Rear)
To maintain FIFO, new elements enter at the end (Rear) of the list.
Question 26 of 50
What is the time complexity for Dequeue operation in a linked list implementation (assuming a head pointer)?
Not quite. Try another option.
Answer: O(1)
Removing from the head of a linked list requires just pointer adjustment, which is constant time.
Question 27 of 50
A queue where elements are removed based on a specific value rather than arrival time is called:
Not quite. Try another option.
Answer: Priority Queue
In a Priority Queue, elements are served based on priority (highest or lowest value), not just FIFO.
Question 28 of 50
Which data structure is most efficient for implementing a Priority Queue?
Not quite. Try another option.
Answer: Binary Heap
A Binary Heap allows insertion and deletion of the highest priority element in O(log n) time, which is generally more efficient than sorted arrays or lists.
Question 29 of 50
In an Ascending Priority Queue, which element is removed first?
Not quite. Try another option.
Answer: The smallest number
In an ascending priority queue, the smallest item has the highest priority and is removed first.
Question 30 of 50
What does 'Deque' stand for?
Not quite. Try another option.
Answer: Double Ended Queue
Deque is an abbreviation for Double Ended Queue.
Question 31 of 50
What is a characteristic feature of a Deque?
Not quite. Try another option.
Answer: Insertion and deletion allowed at both ends
A Deque allows operations (insert/delete) at both the Front and the Rear.
Question 32 of 50
An Input-Restricted Deque allows:
Not quite. Try another option.
Answer: Insertion at one end, deletion at both ends
Input-Restricted means input (insertion) is restricted to one end, but deletion is allowed at both.
Question 33 of 50
An Output-Restricted Deque allows:
Not quite. Try another option.
Answer: Insertion at both ends, deletion at one end
Output-Restricted means output (deletion) is restricted to one end, but insertion is allowed at both.
Question 34 of 50
If you implement a Stack using two Queues, what is the cost of the Push operation usually made to be?
Not quite. Try another option.
Answer: O(n)
To maintain LIFO behavior using FIFO queues, one operation (usually push) becomes expensive O(n) to rearrange elements.
Question 35 of 50
Which of the following is an application of a Stack?
Not quite. Try another option.
Answer: Function call management (Recursion)
The system call stack tracks active subroutines and local variables during recursion.
Question 36 of 50
Which of the following is an application of a Queue?
Not quite. Try another option.
Answer: Breadth First Search (BFS)
BFS uses a queue to explore neighbors level by level.
Question 37 of 50
The Peek operation in a Stack:
Not quite. Try another option.
Answer: Returns the top element without removing it
Peek looks at the Top element but does not modify the stack pointer.
Question 38 of 50
In a linked list implementation of a stack, pushing an element requires allocating a new node and:
Not quite. Try another option.
Answer: Setting its next pointer to the current head
The new node becomes the new head (Top), so it must point to the previous head.
Question 39 of 50
For a queue implemented with a linked list, if Front == NULL, it means:
Not quite. Try another option.
Answer: The queue is empty
If the Front pointer is null, there are no nodes in the linked list queue.
Question 40 of 50
In the array representation of a circular queue, how do you calculate the next position for Rear?
Not quite. Try another option.
Answer: (Rear + 1) % Size
The modulo operator handles the wrap-around from the last index back to index 0.
Question 41 of 50
Evaluate the prefix expression: - + 7 * 4 5 + 2 0
Not quite. Try another option.
Answer: 25
4 5 = 20. + 7 20 = 27. + 2 0 = 2. - 27 2 = 25.
Question 42 of 50
What is the result of converting A * (B + C) to postfix?
Not quite. Try another option.
Answer: A B C + *
Inside parentheses B+C becomes BC+. Then A is multiplied by that result: A BC+ *.
Question 43 of 50
Which data structure supports the 'undo' feature in text editors?
Not quite. Try another option.
Answer: Stack
Undo operations reverse the most recent action, which fits the LIFO nature of a stack.
Question 44 of 50
To reverse a string using a stack, you would:
Not quite. Try another option.
Answer: Push all characters, then pop all characters
Pushing ABC results in C at top. Popping yields C, B, A.
Question 45 of 50
In a priority queue, if two elements have the same priority, how are they typically processed?
Not quite. Try another option.
Answer: FIFO order
Standard convention for stable priority queues is to process elements with equal priority in the order they arrived (FIFO).
Question 46 of 50
How many stacks are needed to implement a Queue efficiently?
Not quite. Try another option.
Answer: 2
Two stacks are required: one for enqueue operations and one to reverse the order for dequeue operations.
Question 47 of 50
When transforming an infix expression to postfix, if the scanned operator has lower precedence than the stack top operator:
Not quite. Try another option.
Answer: Pop the stack top and print it, then repeat comparison
Higher precedence operators in the stack must be applied first, so they are popped before the lower precedence operator is pushed.
Question 48 of 50
In a Deque implemented using a circular array, if Front = 0 and we do deleteFront, what is the new Front?
Not quite. Try another option.
Answer: 1
Assuming the deque is not empty, deleting from index 0 moves the Front pointer to index 1.
Question 49 of 50
Which operation is NOT valid for a standard Stack?
Not quite. Try another option.
Answer: Delete Middle
Standard stacks only allow access and deletion at the Top. Accessing or deleting the middle violates the ADT definition.
Question 50 of 50
What is the minimum number of queues needed to implement a Stack?
Not quite. Try another option.
Answer: 2
Generally, two queues are used to mimic stack behavior (push/pop) by moving elements back and forth, though it can be done with 1 queue if recursion/call-stack is utilized implicitly.
That's unit 3
Answer a few questions and your score shows up here.
Nearly through. Did unit 3 of CSE205 save you a night before the exam?
LPU Notes is free. A student pays for the servers.
Did unit 3 of CSE205 save you a night before the exam?
Then you can help keep it free for the next batch. Ads cover part of the server bill;
the rest comes out of a student's own pocket: the domain, the storage, and keeping
the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason.
to try again.