wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

DS-UNIT-2-Stack Queue

Total questions: 50

Worksheet time: 50mins

Name
Class
Date
1.

In a stack, if a user tries to remove an element from an empty stack it is called _________

a)

Underflow

b)

Empty collection

c)

Overflow

d)

Garbage Collection

2.

Assume that the operators +, -, × are left associative and ^ is right associative. The order of precedence (from highest to lowest) is ^, x , +, -. The postfix expression corresponding to the infix expression a + b × c - d ^ e ^ f is

a)

abc × + def ^ ^ -

b)

abc × + de ^ f ^ -

c)

ab + c × d - e ^ f ^

d)

+ a × bc ^ ^ def

3.

The result evaluating the postfix expression 10 5 + 60 6 / * 8 - is

a)

284

b)

213

c)

142

d)

71

4.

If the elements "A", "B", "C" and "D" are placed in a queue and are deleted one at a time, in what order will they be removed?

a)

ABCD

b)

DCBA

c)

DCAB

d)

ABDC

5.

A normal queue, if implemented using an array of size MAX_SIZE, gets full when?

a)

Rear = MAX_SIZE - 1

b)

Front = (rear + 1)mod MAX_SIZE

c)

Front = rear + 1

d)

Rear = front

6.

How many stacks are needed to implement a queue. Consider the situation where no other data structure like arrays, linked list is available to you.

a)

1

b)

2

c)

3

d)

4

7.

Which of the following is NOT a common operation in a queue data structure?

a)

Enqueue

b)

Dequeue

c)

Peek

d)

Shuffle

8.

How many stacks are needed to implement a queue. Consider the situation where no other data structure like arrays, linked list is available to you.

a)

1

b)

2

c)

3

d)

4

9.

Suppose a circular queue of capacity (n – 1) elements is implemented with an array of n elements. Assume that the insertion and deletion operation are carried out using REAR and FRONT as array index variables, respectively. Initially, REAR = FRONT = 0. The conditions to detect queue full and queue empty are

a)

Full: (REAR+1) mod n == FRONT, empty: REAR == FRONT

b)

Full: (REAR+1) mod n == FRONT, empty: (FRONT+1) mod n == REAR

c)

Full: REAR == FRONT, empty: (REAR+1) mod n == FRONT

d)

Full: (FRONT+1) mod n == REAR, empty: REAR == FRONT

10.

If the sequence of operations - push (1), push (2), pop, push (1), push (2), pop, pop, pop, push (2), pop are performed on a stack, the sequence of popped out values

a)

2,2,1,1,2

b)

2,2,1,2,2

c)

2,1,2,2,1

d)

2,1,2,2,2

11.

The five items: A, B, C, D, and E are pushed in a stack, one after other starting from A. The stack is popped four items and each element is inserted in a queue. The 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

e)

E

12.

Consider the following operations performed on a stack of size 5 : Push (a); Pop() ; Push(b); Push(c); Pop(); Push(d); Pop();Pop(); Push (e) Which of the following statements is correct?

a)

Underflow occurs

b)

Stack operations are performed smoothly

c)

Overflow occurs

d)

None of the above

13.

If elements are inserted in the order -10,-2,-3,4,-1,6 in a queue, then to delete value -3 how many dequeue operations are required?

(a)  

14.

A queue of characters currently contained A, B, C, D.

What would be the contents of queue after the following operation : DELETE, ADD W, ADD X, DELETE, ADD Y.

a)

A,B,C,W,Y

b)

A,B,C,D,W

c)

C,D,W,X,Y

d)

W,Y,X,C,D

15.

If REAR, FRONT are the queue variables, then identify correct statement while inserting a value

a)

FRONT=1

b)

REAR=REAR+1

c)

REAR=REAR-1

d)

FRONT=FRONT-1

16.

In a circular queue, when the rear pointer reaches the end of the array, it should:

a)

stop inserting

b)

move to the front

c)

reset to zero

d)

increase the size of the queue

17.

Which of the following operations is not allowed in a queue?

a)

Random Access

b)

Traversal

c)

Deletion

d)

Insertion

18.

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.

a)

0

b)

7

c)

9

d)

10

19.

Suppose you have the following series of queue operations.

q = Queue();

q.enqueue(1);

q.enqueue(10);

q.enqueue(100);

q.dequeue();

q.dequeue();

What items are returned as output by dequeue operation?

a)

10010

b)

101

c)

110

d)

10010

20.

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.

21.

Suppose you have the following series of queue operations.

q = Queue();

q.enqueue('hello');

q.enqueue('god');

q.enqueue(3);

q.dequeue();

What items are left on the queue?

a)

'hello', 'god'

b)

'god', 3

c)

'hello', 3

d)

'hello', 'god', 3

22.

In a circular queue, how do you increment the rear end of the queue?

a)

rear = rear + 1

b)

(rear + 1) % queueSize

c)

(rear % queueSize) + 1

d)

rear = rear - 1

23.

In linked list implementation of a queue, the important condition for a queue to be empty is?

a)

FRONT is null

b)

REAR is null

c)

LINK is empty

d)

None of the mentioned

24.

Let the following circular queue can accommodate maximum six elements with the following data


front = 2 rear = 4

queue = _______; L, M, N, ___, ___


What will happen after ADD O operation takes place?

a)

front = 2 rear = 5

queue = ______; L, M, N, O, ___

b)

front = 3 rear = 5

queue = L, M, N, O, ___

c)

front = 3 rear = 4

queue = ______; L, M, N, O, ___

d)

front = 2 rear = 4

queue = L, M, N, O, ___

25.

The essential condition which is checked before insertion in a linked queue is?

a)

Underflow

b)

Overflow

c)

Front value

d)

Rear value

26.

What is the reason for using a "circular queue" instead of a regular one?

a)

running time of enqueue() is improved

b)

reuse empty spaces

c)

you can traverse all the elements more efficiently

d)

none of the above

27.

The postfix form of the expression (A+ B)*(C*D- E)*F / G is?

a)

AB + CDE * - * F *G /

b)

AB+ CD*E - FG /**

c)

AB + CD* E - F **G /

d)

AB + CD* E - *F *G /

28.

The prefix form of A-B/ (C * (D * E)) is?

a)

-/*ACB*DE

b)

-ABCD**DE

c)

-A/B*C*DE

d)

-A/BC**DE

29.

Which of the following is based on the principle of Last In First Out?

a)

Stack

b)

Queue

c)

Both

d)

None of These

30.

Which of the following data structures is used in recursion?

a)

Stack

b)

Queue

c)

Both

d)

None of these

31.

Which of the following is the correct value of TOP if stack is empty?

a)

0

b)

Max-1

c)

-1

d)

None of these

32.

Which of the following is the correct value of TOP if stack is full?

a)

0

b)

Max-1

c)

-1

d)

None of these

33.

Which of the following conditions are met if queue is empty?

a)

Front = -1 and Rear = -1

b)

Rear = Max - 1

c)

Rear = Front

d)

None of these

34.

Which of the following conditions are met if a queue is full?

a)

Front = -1 and Rear = -1

b)

Rear = Max - 1

c)

Rear = Front

d)

None of these

35.

Which of the following conditions are met if a queue has only one element?

a)

Front = -1 and Rear = -1

b)

Rear = Max - 1

c)

Rear = Front

d)

None of these

36.

The problem faced in Linear Queue is handled by implementing which of the following?

a)

Circular Queue

b)

Stack

c)

Doubly ended queue

d)

None of these

37.

The underflow function, in a queue is handled returns a True in which of the following cases?

a)

Front = -1 and rear = -1

b)

Rear = Front

c)

Rear = Max - 1

d)

None of these

38.

The underflow function, in a Stack returns a True in which of the following cases?

a)

Top = -1

b)

Top = Max - 1

c)

Both

d)

None of these

39.

The overflow function, in a Stack returns a True in which of the following cases?

a)

Top = -1

b)

Top = Max - 1

c)

Both

d)

None of these

40.

The overflow function, in a Queue returns a True in which of the following cases?

a)

Front = -1 and rear = -1

b)

Rear = Front

c)

Rear = Max - 1

d)

None of these

41.

Which of the following is used in spooling?

a)

Stack

b)

Queue

c)

Both

d)

None of these

42.

In a circular queue, how do you increment the rear end of the queue?

a)

rear++

b)

(rear+1) % Number of Item

c)

(rear % Number of Item)+1

d)

rear–

43.

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

a)

7

b)

9

c)

10

d)

0

44.

If the numbers 5, 10, 3, 42 are enqueued onto a queue in that order, what does dequeue return?

a)

5

b)

10

c)

3

d)

42

45.

The essential condition which is checked before insertion in a linked queue is?

a)

Underflow

b)

Overflow

c)

Front value

d)

Rear value

46.

A queue of characters currently contained A,B,C,D What would be the contents of queue after the following operationDELETE, ADD W, ADD X, DELETE, ADD Y.

a)

A,B,C,W,Y

b)

A,B,C,D,W

c)

C,D,W,X,Y

d)

W,Y,X,C,D

47.

What will the stack contain after the following actions?

Push(1);

Push(2);

Push(3);

Push(4);

Pop();

Pop();

Push(5);

a)

1, 2, 3

b)

1, 2, 3, 5

c)

1, 2, 3, 4, 5

d)

1, 2, 5

48.

Convert the infix exression

(A + B) * (C + D)

to Postfix.

a)

A B C * + D +

b)

A B + C D + *

c)

A B * C D * +

d)

A B + C + D +

49.

Act of adding values into a stack is called

a)

Popping

b)

Polling

c)

Pushing

d)

None

50.

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

a)

1

b)

3

c)

2

d)

4