cs17201-ds-assignment-unit-i-q
cs17201-ds-assignment-unit-i-q
3. Tower of Hanoi can be regarded as a problem of which of the following data structures?
(a)Stack
(b)Queue
(c)Graph
(d)Tree
4. Recursive function calls are executed using which of the following data structures?
(a)Stack
(b)Queue
(c)Graph
(d)Tree
5. If 2, 1, 5, 8 are the stack contents with element 2 being at the top of the stack, then what will
be the stack contents after following operations:
Push (11)
Pop ( )
Pop ( )
Pop ( )
Push(7)
(a)11, 2, 1
(b)8, 11, 7
(c)7, 5, 8
(d)5, 8, 7
6. Which of the following is best suitable for storing a simple collection of employee records?
(a)Stack
(b)Queue
(c)Array
(d)None of the above
7. If ‘top’ points at the top of the stack and ‘stack []’ is the array containing stack elements, then
which of the following statements correctly reflect the Push Operation for inserting ‘item’ into
the stack?
(a)top = top + 1; stack [top] = item;
(b)stack [top] = item; top = top + 1;
(c)stack [top++] = item;
(d)Both (a) and (c) are correct
8. If ‘top’ points at the top of the stack and ‘stack []’ is the array containing stack elements, then
which of the following statements correctly reflect the pop operation?
(a)top = top – 1; item = stack [top];
(b)item = stack [top]; top = top – 1;
(c)item = stack [--top];
(d)Both (b) and (c) are correct
9. If a pop operation is performed on an empty stack, then which of the following situations will
occur?
(a)Overflow
(b)Underflow
(c)Array out of bound
(d)None of the above
15. If 1, 2, 3, 4 are the queue contents with element 1 at the front and 4 at the rear, then what will
be the queue contents after following operations:
Insert (5)
Delete ( )
Delete ( )
Delete ( )
Insert (6)
Insert (–1)
Delete ( )
(a)5, 6, –1
(b)4, 5, 6, –1
(c)1, 2, 6
(d)1, 2, 6, –1
16. Which of the following is best suitable for implementing a print scheduler?
(a)Stack
(b)Queue
(c)Array
(d)None of the above
17. If ‘front’ points at the front end of the queue, ‘rear’ points at the rear end of the queue and
‘queue []’ is the array containing queue elements, then which of the following statements
correctly reflects the insert operation for inserting ‘item’ into the queue?
(a)rear = rear + 1; queue [rear] = item;
(b)front = front + 1; queue [front] = item;
(c)queue [rear++] = item;
(d)Both (a) and (c) are correct
18. If ‘front’ points at the front end of the queue, ‘rear’ points at the rear end of the queue and
‘queue []’ is the array containing queue elements, then which of the following statements
correctly reflects the delete operation for deleting an element from the queue?
(a)item = queue [rear]; rear = rear + 1;
(b)item = queue [front]; front = front + 1;
(c)item = queue [++front];
(d)Both (b) and (c) are correct
ANSWERS
1. 2. 3. 4. 5. 6. 7. 8. 9. 10.
11. 12. 13. 14. 15. 16. 17. 18. 19. 20.
Column A Column B
Infix +/ABC
Prefix AB/C+
Postfix A/B+C
(a+b)
Stack is __________
((a+b)
Stack is __________
(a+b))
Stack is __________
(a+b]
Column A Column B
Queue Overflow
Queue Underflow
Stack Overflow
Stack Underflow
7 8 + 3 2 + /