wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Stacks

Total questions: 17

Worksheet time: 10mins

Name
Class
Date
1.

Which condition does stack apply?

a)

FILO

b)

LIFO

c)

FIFO

d)

LILO

2.

Only top element can be accessed in stack

a)

True

b)

False

3.

Operation to add values into stack is called

a)

Push

b)

Pop

c)

None

d)

Empty

4.

Operation to remove an element from the stack

a)

Pop

b)

Push

c)

Create

d)

Emplace

5.

Operation that returns the topmost element of the stack

a)

Top

b)

Empty

c)

Size

d)

Swap

6.

Operation to construct and insert new element to the top of the stack

a)

Emplace

b)

Top

c)

Push

d)

Size

7.

If the sequence of operations

push(1)

push(3)

pop

push(2)

push(2)

pop

pop

pop

push(3)

pop

are performed on a stack, the order of popped out values

a)

3, 2, 2, 3, 1

b)

3, 2, 1, 3, 2

c)

2, 3, 2, 3, 1

d)

1, 3, 2, 2, 3

8.

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)

Stack operations performed smoothly

b)

Underflow occurs

c)

Overflow occurs

d)

None of the above

9.

Which of the following is not an application of stack?

a)

Job schedulling

b)

Undo-redo feature

c)

Infix conversion

d)

Tower of hanoi

10.

Which of the following statement about stack data structure is not correct?

a)

Stack is a FIFO data structure

b)

Stack data structure can be implemented using linked list

c)

New element can only be added at the top of the stack

d)

The last node at the bottom of the stack has a NULL link

11.

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

a)

A

b)

B

c)

C

d)

D

12.

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)

The number of elements left in the stack

a)

1

b)

2

c)

3

d)

4

13.

If a user tries to remove an element from empty stack it is called

a)

Underflow

b)

Overflow

c)

Empty collection

d)

Garbage collection

14.

Convert to postfix form of A * B + C / D is

a)

AB*CD/+

b)

*AB/CD+

c)

A*BC+/D

d)

ABCD+/*

15.

Convert the following Infix to Postfix form

v * w + (x * y) + z

a)

vw*xy*+z+

b)

vw*xy+*z*

c)

vw+xy*z+

d)

none

16.

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

a)

-18

b)

1

c)

40

d)

74

17.

Analyze the following code and determine the order of stacks from the shortest to longest

stack1.push(12);

stack2.push(24);

stack3.push(11);

stack1.push(37);

stack2.push(59);

stack3.push(46);

stack1.pop();

stack1.pop();

stack2.pop();

stack1.emplace(12);

stack2.emplace(20);

stack3.emplace(41);

stack1.emplace(19);

stack2.emplace(23);

stack3.emplace(10);

stack1.swap(stack2);

stack2.swap(stack3);

a)

Stack2, stack1, stack3

b)

Stack1, stack2, stack3

c)

Stack3, stack2, stack1

d)

None of the above