NEW
Font size
WorksheetsStack and Queue
Total questions: 25
Worksheet time: 14mins
Choose correct output for the following sequence of operations.
push(5)
push(8)
pop
push(2)
push(5)
pop
pop
pop
push(1)
pop
8 5 2 5 1
8 5 5 2 1
8 2 5 5 1
8 1 2 5 5
Stack can be implemented using _________ and ________ ?
Array and Binary Tree
Linked List and Graph
Array and Linked List
Queue and Linked List
When the function calls another function then the details of the previous function are stored in Stack?
Yes
No
Consider an empty stack of an integers. Let the numbers 4,5,6,7,8 to be pushed on to this stack only in the order they appeared from left to right. Let P indicates PUSH and Q indicates POP operation. What sequence of operations should be performed on stack in order to get the output as 548.
PPPXPPXX
PPXPPPXX
PPXXPPPX
PXXPPXPX
What is the postfix expression for the corresponding infix expression?
a+b*c+(d*e)
abc*+de*+
abc+*de*+
a+bc*de+*
abc*+(de)*+
What is the postfix expression for the infix expression?
a-b-c
abc--
ab – c –
– -abc
-ab-c
Which of the following statement is incorrect with respect to infix to postfix conversion algorithm?
operand is always placed in the output
operator is placed in the stack when the stack operator has lower precedence
parenthesis are included in the output
higher and equal priority operators follow the same condition
What is the corresponding postfix expression for the given infix expression?
a+(b*c(d/e^f)*g)*h)
ab*cdef/^*g-h+
abcdef^/*g*h*+
abcd*^ed/g*-h*+
abc*de^fg/*-*h+
What is the correct postfix expression for the following expression?
a+b*(c^d-e)^(f+g*h)-i
abc^de-fg+*^*+i-
abcde^-fg*+*^h*+i-
abcd^e-fgh*+^*+i-
ab^-dc*+ef^gh*+i-
In linked list implementation of a queue, where does a new element be inserted?
At the head of link list
At the tail of the link list
At the centre position in the link list
None
If the MAX_SIZE is the size of the array used in the implementation of circular queue, array index start with 0, front point to the first element in the queue, and rear point to the last element in the queue. Which of the following condition specify that circular queue is FULL?
Front=rear= -1
Front=(rear+1)%MAX_SIZE
Rear=front+1
Rear=(front+1)%MAX_SIZE
A circular queue is implemented using an array of size 10. The array index starts with 0, front is 6, and rear is 9. The insertion of next element takes place at the array index.
0
7
9
10
Which one of the following is not the application of the stack data structure
String reversal
Recursion
Backtracking
Asynchronous data transfer
What is the outcome of the prefix expression +, -, *, 3, 2, /, 8, 4, 1 ?
12
11
5
4
If the elements '1', '2', '3' and '4' are inserted in a queue, what would be order for the removal?
If the elements '1', '2', '3' and '4' are inserted in a stack, what would be order for the removal?
1234
4321
4321
1234
3241
4123
None
The time complexity of enqueue operation in Queue is __
O(1)
O(n)
O(logn)
O(nlogn)
Consider the following code.
int fun() {
if(isEmpty())
{
return -10;
}
else
{
int n;
n= q[front];
front++;
return n;
}
}
Which operation does the above code perform?
Enqueue
Dequeue
Return the front element
Both b and c
What would be the output after performing the following operations in a Deque?
Insertfront(10);
Insertfront(20);
Insertrear(30);
Insertrear(40);
Deletefront();
Insertfront(50);
Deleterear();
Display();
10, 20, 30
50, 10, 30
40, 20, 30
None of the above
Consider the implementation of the singly linked list having the head pointer only in the representation. Which of the following operations can be performed in O(1) time?
i) Deletion of the last node in the linked list
ii) Insertion at the front of the linked list
iii) Deletion of the first node in the linked list
iv) Insertion at the end of the linked list
ii
both ii and iii
both i and iv
both i and ii
Find the output of the following prefix expression.
*+2-2 1/-4 2+-5 3 1
2
12
10
4
If -*+abcd = 11, find a, b, c, d using evaluation of prefix algorithm.
a=2, b=3, c=5, d=4
a=1, b=2, c=5, d=4
a=5, b=4, c=7,d=5
a=1, b=2, c=3, d=4
n the given C snippet, find the statement number that has error.
//C code to push an element into a stack
1. void push( struct stack *s, int x)
2. {
3. if(s->top==MAX-1)
4. {
5. printf(“stack overflow”);
6. }
7. else
8. {
9. s->items[++s->top]=x;
10. s++;
11. }
12. }
1
9
10
11
The result of evaluating the postfix expression 5, 4, 6, +, , 4, 9, 3, /, +, is?
600
350
650
588
Consider the following operation performed on a stack of size 5.
Push(1);
Pop();
Push(2);
Push(3);
Pop();
Push(4);
Pop();
Pop();
Push(5);
After the completion of all operation, the no of element present on stack are
1
2
3
4
Consider the usual implementation of parentheses balancing program using stack. What is the maximum number of parentheses that will appear on stack at any instance of time during the analysis of ( ( ) ( ( ) ) ( ( ) ) )?
1
2
3
4
