wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Queue & Stack Data Structures

Total questions: 80

Worksheet time: 45mins

Name
Class
Date
1.

If the insertion and deletion happens from both the ends then the queue is called a______Queue

a)

a) Deque

b)

b) Header

c)

c) Queue

d)

d) Circular Queue

2.

Process of inserting an element in stack is called ____________

a)

Create

b)

Push

c)

Evaluation

d)

Pop

3.

Entries in a stack are “ordered”. What is the meaning of this statement?

a)

A collection of stacks is sortable

b)

Stack entries may be compared with the ‘<‘ operation

c)

The entries are stored in a linked list

d)

There is a Sequential entry that is one by one

4.

Which of the following applications may use a stack?

a)

a) A parentheses balancing program

b)

b) Tracking of local variables at run time

c)

c) Compiler Syntax Analyzer

d)

d) Data Transfer between two asynchronous process

5.

What is the value of the postfix expression 6 3 2 4 + – *:

a)

1

b)

14

c)

74

d)

-18

6.

The data structure required to check whether an expression contains balanced parenthesis is?

a)

a) Stack

b)

b) Queue

c)

c) Array

d)

d) Tree

7.

Circular Queue is also known as ________

a)

a) Ring Buffer

b)

b) Square Buffer

c)

c) Rectangle Buffer

d)

d) Curve Buffer

8.

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)

a) ABCD

b)

b) DCBA

c)

c) DCAB

d)

d) ABDC

9.

What does the following function do for a given Linked List with first node as head?

void fun1(struct node* head)

{

if(head == NULL)

return;

fun1(head->next);

printf("%d ", head->data);

}

a)

a) Prints all nodes of linked lists

b)

b) Prints all nodes of linked list in reverse order

c)

c) Prints alternate nodes of Linked List

d)

d) Prints alternate nodes in reverse order

10.

Linked list data structure offers considerable saving in _____________

a)

a) Computational Time

b)

b) Space Utilization

c)

c) Space Utilization and Computational Time

d)

d) Speed Utilization

11.

Which of the following is/are the levels of implementation of data structure

a)

Abstract level

b)

Application level

c)

Implementation level

d)

All of the above

12.

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

13.

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

14.
Are stacks FIFO or FILO?
a)
FILO
b)
FIFO
c)
LIFO
d)
LILO
15.

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

16.

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

a)

1

b)

2

c)

3

d)

4

17.

Which of the following is true about linked list implementation of queue?

a)

In push operation, if new nodes are inserted at the beginning of linked list, then in pop operation, nodes must be removed from end.

b)

In push operation, if new nodes are inserted at the end, then in pop operation, nodes must be removed from the beginning.

c)

Both of the above

d)

None of the above

18.

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

19.

Consider the following operation along with Enqueue and Dequeue operations on queues, where k is a global parameter.

What is the worst case time complexity of a sequence of n MultiDequeue() operations on an initially empty queue?

a)

O(n)

b)

O(n+k)

c)

O(nk)

d)

O(n^2)

20.

Suppose implementation supports an instruction REVERSE, which reverses the order of elements on the stack, in addition to the PUSH and POP instructions. Which one of the following statements is TRUE with respect to this modified stack?

a)

A queue cannot be implemented using this stack.

b)

A queue can be implemented where ENQUEUE takes a single instruction and DEQUEUE takes a sequence of two instructions.

c)

A queue can be implemented where ENQUEUE takes a sequence of three instructions and DEQUEUE takes a single instruction.

d)

A queue can be implemented where both ENQUEUE and DEQUEUE take a single instruction each.

21.

Let Q denote a queue containing sixteen numbers and S be an empty stack. Head(Q) returns the element at the head of the queue Q without removing it from Q. Similarly Top(S) returns the element at the top of S without removing it from S. Consider the algorithm given below.


The maximum possible number of iterations of the while loop in the algorithm is

a)

16

b)

32

c)

64

d)

256

22.

Following is C like pseudo code of a function that takes a number as an argument, and uses a stack S to do processing.


What does the above function do in general?

a)

Prints binary representation of n in reverse order

b)

Prints binary representation of n

c)

Prints the value of Logn

d)

Prints the value of Logn in reverse order

23.

The following postfix expression with single digit operands is evaluated using a stack:

Note that ^ is the exponentiation operator. The top two elements of the stack after the first * is evaluated are:

a)

6,1

b)

5,7

c)

3,2

d)

1,5

24.

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

25.

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

26.

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

27.

Which of the following is not an inherent application of stack?

a)

Implementation of recursion

b)

Evaluation of a postfix expression

c)

Job scheduling

d)

Reverse a string

28.

In linked list implementation of a queue, where does a new element be inserted?

a)

At the head of link list

b)

At the centre position in the link list

c)

At the tail of the link list

d)

None of the mentioned

29.

In linked list implementation of a queue, from where is the item deleted?

a)

At the head of link list

b)

At the centre position in the link list

c)

At the tail of the link list

d)

None of the mentioned

30.

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–

31.

What is the term for inserting into a full queue known as?

a)

overflow

b)

underflow

c)

null pointer exception

d)

all of the mentioned

32.

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, ___

33.

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

34.

In Queue Insertion & Deletion take place at ________________.

a)

same end

b)

first end

c)

different end

d)

last end

35.

One difference between a queue and a stack is:

a)

Queues require dynamic memory, but stacks do not

b)

Stacks require dynamic memory, 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.

36.

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

37.

Queue can be implemented using a list?

a)

True

b)

False

38.

What is the term for inserting into a full queue known as?

a)

underflow

b)

overflow

c)

front

d)

rear

39.

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

a)

Underflow

b)

Overflow

c)

Front value

d)

Rear value

40.

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

41.

If front=rear ,then the queue is?

a)

full

b)

undeflow

c)

overflow

d)

empty

42.

a QUEUE in a computer acts just like people queuing for a bus - the first person in queue is going to be the first to get on the bus.

a)

True

b)

False

43.

A Queue uses a front and rear pointer?

a)

True

b)

False

44.
Which of these data structures is FIFO
a)
Stack
b)
Queue
c)
Binary Tree
d)
Double linked list
45.
What is returned by values[5]?
a)
9
b)
12
c)
6
d)
8
46.

A Queue can only store 6 data items. The Queue is sent 4 data items: Bert, Cynthia, Cedric and Albert. Where does the "Rear" index pointer point?

a)

0

b)

1

c)

2

d)

3

47.

A Queue can only store 6 data items. The Queue is sent 4 data items: Bert, Cynthia, Cedric and Albert. Where does the "Front" pointer point?

a)

Bert

b)

Cynthia

c)

Cedric

d)

Albert

48.

If the character 'V', 'I', 'V', 'A' are placed in queue (in order), and being removed one at a time, choose the order for the character after that

a)

AVIV

b)

VIVA

c)

VAVI

d)

IVAV

49.

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

a)

Underflow

b)

Empty collection

c)

Overflow

d)

Garbage Collection

50.

Process of inserting an element in stack is called ____________

a)

Create

b)

Push

c)

Evaluation

d)

Pop

51.

Consider the usual algorithm for determining whether a sequence of parentheses is balanced.

Suppose that you run the algorithm on a sequence that contains 2 left parentheses and 3 right parentheses (in some order).

The maximum number of parentheses that appear on the stack AT ANY ONE TIME during the computation?

a)

1

b)

2

c)

3

d)

4 or more

52.

User perform following operations on stack of size 5 then -

push(1);

pop();

push(2);

push(3);

pop();

push(2);

pop();

pop();

push(4);

pop();

pop();

push(5);

a)

Overflow Occurs

b)

Stack Operations will be performed Smoothly

c)

Underflow Occurs

d)

None of these

53.

What is the value of the postfix expression 6 3 2 4 + – *

a)

1

b)

40

c)

74

d)

-18

54.

To evaluate an expression without any embedded function calls:

a)

One stack is enough

b)

Two stacks are needed

c)

As many stacks as the height of the expression tree are needed

d)

A Turing machine is needed in the general case

55.

What will be the postfix form of the above expression -

(A+B)∗(C∗D-E)∗F/G

a)

None of these

b)

A B + C D ∗ E − F G ∗ / ∗

c)

A B + C D E ∗ − F G / ∗ ∗

d)

A B + C D ∗ E − F G / ∗ ∗

56.

Which one of the following is an application of Stack Data Structure?

a)

Managing function calls

b)

The stock span problem

c)

Arithmetic expression evaluation

d)

All of the above

57.

List of data in which element can be inserted and removed at the same end is called as __________.

a)

array

b)

stack

c)

linked list

d)

queue

58.

In a Queue Data Structure...

a)

New elements may only be added to the end of the queue

b)

Elements may only be retrieved from the front of the queue.

c)

Elements may only be retrieved from the end of the queue.

d)

New elements may only be added to the front of the queue

59.

Select ALL the situations that a Queue data structure would be used?

a)

Printer in a room full of computers

b)

Characters typed on a keyboard

c)

Back Button

d)

Undo Button

60.

Which is the correct operation for:

"Remove the front item from the queue and return it"

a)

dQueue()

b)

de.Queue(Item)

c)

deQueue()

d)

item.remove()

e)

Cant be performed on a Queue Data Structure.

61.

Which is the correct operation for:

"Remove the rear item from the queue and return it"

a)

dQueue()

b)

de.Queue(Item)

c)

deQueue()

d)

item.remove()

e)

Cant be performed on a Queue Data Structure.

62.

Which is the correct operation for:

"Add a item to the front of the queue."

a)

enQueue(item)

b)

Append.Queue(item)

c)

enQueue()

d)

AddItem(EnQueue())

e)

Cant be performed on a Queue.

63.

Select operations that can be performed on a Queue Data Structure...

a)

isEmpty()

b)

pop()

c)

push()

d)

isFull()

e)

Append(Item)

64.

Where would pointers be pointing if...

  1. Eli leaves the Queue
  2. Adam joins the Queue
a)

front = 0 rear = 3

b)

front = 1 rear = 4

c)

front = 2 rear = 3

d)

front = 0 rear = 4

e)

front = 0 rear = 4

65.

Where would pointers be pointing if...

  1. Eli leaves the Queue.
  2. Hanna joins the Queue.
  3. Adam joins the Queue.
  4. Jason leaves the Queue.
a)

front = 0 rear = 5

b)

front = 1 rear = 4

c)

front = 2 rear = 4

d)

front = 0 rear = 4

e)

front = 2 rear = 5

66.

What would happen if...

deQueue()

enQueue(Hanna)

enQueue(Steve)

enQueue(Jack)

a)

front = 1 rear = 0

*and Steve would be unable to be added to position 0.

b)

front = 1 rear = 5

*and Jack would be unable to be added to position 0

c)

front = 0 rear = 5

d)

front = 0 rear = 4

e)

front = 1 rear = 4

67.

Stacks follows____________ order

a)

FIFO (First In First Out )

b)

LIFO (Last In First Out)

c)

Random

d)

FILO(First In Last Out)

68.

The examples of Linear Data Structures are

a)

Stacks,Queues,Linked list

b)

int,float,complex

c)

Operators,tokens,punctuators

d)

Tree, graph

69.

Main Operations in Stacks are Called

a)

Insertion and deletion

b)

Push and Pop

c)

append and insertion

d)

append and pop

70.

Insertion in Queue is done at_____ end , and deletion is at _______ end

a)

start, last

b)

front, rear

c)

rear, front

d)

begin, stop

71.

Main Operations in Queue are Called

a)

Enqueue and Dequeue

b)

Append and Insertion

c)

Push and Pop

d)

append and traverse

72.

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

a)

ABCD

b)

ABDC

c)

CDBA

d)

DCAB

73.

While converting infix to postfix expression, what would be pushed into the stack?

a)

only operators

b)

opening symbol '('

c)

operators and opening symbol

d)

operands

e)

operators and operands

74.

While evaluating the postfix expression, what would be pushed into the stack?

a)

operands

b)

operators

c)

operators and opening symbols

d)

operators and operands

e)

stack is not used for this evaluation

75.

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

76.

Pushing an element into a stack already having six elements and the size is six, then the stack has

a)

Overflow

b)

Crash

c)

Underflow

d)

User flow

77.

A stack is a data structure in which elements

a)

can be added to any position and removed only from the top

b)

can be only added to the top and removed from any position

c)

can be added and removed from the top only

d)

can be added and removed from any position

78.

The data structure required to check whether an expression contains balanced parenthesis is?

a)

a) Stack

b)

b) Queue

c)

c) Array

d)

d) Tree

79.

Suppose you have the following series of queue operations.

q = Queue();

q.enqueue('hello');

q.enqueue('dog');

q.enqueue(3);

q.dequeue();

What items are left on the queue?

a)

'hello', 'dog'

b)

'dog', 3

c)

'hello', 3

d)

'hello', 'dog', 3

80.

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 the output?

a)

10010

b)

101

c)

110

d)

10010