0% found this document useful (0 votes)
228 views

MCQ STACK Queue

Questions on stack and Queue

Uploaded by

Gourab
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
228 views

MCQ STACK Queue

Questions on stack and Queue

Uploaded by

Gourab
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

MCQ- STACK AND QUEUE

1. The following sequence of operations is performed on a stack: push(1), push(2),pop, push(1),


push(2), pop, pop, pop, push(2 ),pop. The sequence of popped out values are
a) 2,2,1,2,1 b) 2,2,1,1,2 c) 2,1,2,2,1 d) 2,1,2,2,2

2. A stack is implemented using an array with the following declaration:


int stack [100] ; int stacktop=0;
To perform the POP operation, which of the following is correct?
a) x=stack [stack top++] b) x= stack [++stack top]
c) x=stack [stack top--] d) x= stack [--stack top]

3. Stack is used in
a) Recursion b) Invoking functions c) All of the above d) None of the above

4. The other name for prefix notation is


a) Reverse polish b) Polish c) Infix d) None of the above

5. Stack can be implemented using


a) Arrays b) Linked lists c) both a & b d) None of the above

6. In Stack data structure, insertions and deletions are made at


a) both ends b) one end only c) middle of the stack d) None of the these

7. What is the value of the postfix expression 6 3 2 4 + - * :


a) Something between -15 and -100 b) Something between -5 and -15

c) Something between 5 and -5 d) Something between 5 and 15

e) Something between 15 and 100

8. The operation for adding an entry to a stack is traditionally called:


a) Add b) Append c) Insert d) Push

9. The operation for removing an entry from a stack is traditionally called:


a) Delete b) Peek c) Pop d) Remove

10. Which of the following stack operations could result in stack underflow?
a) Is_empty b) Pop c) Push d) Two or
more of the above answers.
11. The postfix equivalent of the prefix *+ab-cd is
a) AB+CD-* b) abcd+-* c) ab+cd*- d) ab+-cd*

12. A postfix expression for the infix expression a+b*(c+d)/f+d*e


a) ab+cd+*f/d+e* b) abcd+*f/+de*+ c) a*b+cd/f*de++ d) None of these

13. A prefix expression for the infix expression a*(b+c)/e-f


a)/*a+bc-ef b) -/*+abcef c) -/*a+bcef d) None of these
14. Translating the infix expression(P) into postfix notation, we get
[P = A + ( B C  ( D / ( E + F ) )  G)  H ]
a) ABC  DEF / + G  H  +
b) ABC  + DEF + /  G  H  +
c) ABC  DEF + / G  H  +
d) None of these
15. Which data structure is needed to convert infix notations to postfix notations?
a) Linear list b) Queue c) Tree d) Stack

16. Stack is ………………


a) a linear data structure b) a nonlinear data structure c) None of the above

17. Stack is also called as


a) FIFO b) LIFO c) both (i) and (ii) d) None of the above

18. The number of elements that can be removed from the stack at any time is ………………
a) 3 b)4 c)1 d) 0

19. Suppose we have an array implementation of the stack structure, with ten items in the stack stored
at data[0] through data[9]. The CAPACITY is 42. Where does the push method place the new
entry in the array?
a) data[0] b) data[1] c) data[9] d) data[10]

20. Which data structure is used in evaluating mathematical expressions with parentheses?
a)Stack b) Queue c) Tree d) Graph

21. Which of the following applications may use a stack?


a) A parentheses balancing program. b) Keeping track of local variables at run time.
c) Syntax analyzer for a compiler. d) All of the above.

22. The five items A, B, C, D, E are pushed in a stack, one after the other starting from A. The stack
is popped four times and each element is inserted in a queue. Then two elements are deleted from
the queue and pushed back on the stack. Now one item is popped from the stack. The popped
item is
a) A b) B c) C d) D
23. Suppose you opened a notepad, a music player, an excel sheet, and also you are doing your data
structure programming simultaneously. Your OS implements which data structure for it.
a) Stack b) Queue c) Tree d) Linked List
24. Simulations are implemented using ______________________.
a) Stack b) Queue c) Linked List d) Tree

25. The evaluation of the postfix expression 3,5,7,*,+,12,% is


a)2 b)3 c)0 d)3.17
26. If we evaluate the following postfix expression 23 5 7 * - 12 +
The result will be
a) 12 b) 0 c) -12 d) 35
27. The number of stacks required to implement mutual recursion is
a) 3 b)2 c)1 d)None of these
28. Insertion in stack is done in
a) front b) rear c) top d) bottom
29. The integers 1,2,3,4 are pushed into the stack in that order. They may be popped out of the stack
in any valid order. The integers, which are popped out produce a permutation of the numbers 1, 2,
3, 4.Which of the following permutation can never be produced in such a way?
a) 1,2,3,4 b) 4,2,3,1 c) 4,3,2,1 d) 3,2,4,1

30. Which data structure is used to manage Printer Buffer?


a) Stack b) Queue c) Linked List d) Tree
31. Which of the following is essential for converting an infix expression to postfix notation?
a) A parse tree b) An operand stack
c) An operator stack d)None of these

32. Ascending priority queue is one in which the item removed is


a) the smallest item b) the largest item c) any item

33. Descending priority queue is one in which the item removed is


a) the smallest item b) the largest item c) any item

34. One difference between a queue and a stack is:


a) Queues require linked lists, but stacks do not.

b) Stacks require linked lists, but queues do not.

c) Queues use two ends of the structure; stacks use only one.

d) Stacks use two ends of the structure, queues use only one.

35. If the characters ‘D’, ‘C’, ‘B’, ‘A’ are placed in a queue (in that order), and then removed one at a
time, in what order will they be removed?
a) ABCD b) ABDC c) DCAB d) DCBA

36. Let P be the queue of integers defined as follows


#define MAX 50
struct queue {
int items[MAX];
int front, rear;
}q;
To insert an elements in the queue we can use
a)++q.items[q.rear]=x; b) q.items[++q.rear]=x; c) q.items[++q.rear]++=x;
37. The deque can be used
a) as a stack b) as a queuec) both as a stack and as a queue d) None of the above

38. I) In the case of priority queue elements can be inserted


a)at the ends b) at any position c) a and b d) None of the above
II) Priroty queue can be implemented using

a)Array b)Linked list c)Heap d)All of these


39. Suppose we have a circular array implementation of the queue structure, with ten items in the
queue stored at data[2] through data[11]. The current capacity is 42. Where does the insert
method place the new entry in the array?
a) data[1] b) data[2] c) data[11] d) data[12]

40. If data is a circular array of CAPACITY elements, and rear is an index into that array, what is the
formula for the index after rear?
a) (rear % 1) + CAPACITY b) rear % (1 + CAPACITY)
c) (rear + 1) % CAPACITY d) rear + (1 % CAPACITY)
41. Suppose getFront is called on a priority queue that has exactly two entries with equal priority.
How is the return value of getFront selected?
a) One is chosen at random b) The one which was inserted first.
c) The one which was inserted most recently. d) This can never happen (violates the
precondition)

42. Queue is implemented with a linked list, keeping track of a front node and a rear node with two
reference variables. Which of these reference variables will change during an insertion into a
NONEMPTY queue?
a) Neither changes b) Only front changes c) Only rear changes. d) Both change

43. Which of the following data structure may give overflow error, even though the current number
of elements in it, is less than its size.
a) Simple queue b) Circular queue c) Stack d) None of the above.

44. A linear list in which elements can be added or removed at either end but not in the middle is
known as
a)Stack b) Queue c) Dequeue d) Heap

45. The initial configuration of queue a,b,c,d(‘a’ is at the front).To get the configuration d,c,b,a
One needs a minimum of
a) 2 deletions and 3 additions
b) 3 deletions and 2 additions
c) 3 deletions and 3 additions
d) 3 deletions and 4 additions
46. The rear and front end of a linear queue is used for
a) deletion, insertion b) searching, sorting c) insertion deletion d)none
47. Queue is implemented with a circular array, keeping track of front, rear, and manyItems (the
number of items in the array). Suppose front is zero, and rear is one less than the current capacity.
What can you tell me about many Items?
a) manyItems must be zero.
b) manyItems must be equal to the current capacity.
c) count could be zero or the capacity, but no other values could occur.
d) None of the above.

You might also like