wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Quiz on Stack Data Structure

Total questions: 99

Worksheet time: 50mins

Name
Class
Date
1.

A stack follows which principle?

a)

FIFO

b)

LILO

c)

LIFO

d)

FILO

2.

In a stack, insertion happens at the _____.

a)

Middle

b)

Bottom

c)

Top

d)

Random position

3.

In a stack, deletion happens at the _____.

a)

Middle

b)

Bottom

c)

Top

d)

Random position

4.

The bottom of the stack is the end where _____ happens.

a)

Insertion

b)

Deletion

c)

No operations

d)

Both insertion and deletion

5.

Which one is NOT an application of stacks?

a)

Undo operation

b)

Back button of browser

c)

Queue management

d)

Reversing an array

6.

Push means _____.

a)

Remove an element

b)

Add an element

c)

Check size

d)

Access bottom

7.

Pop means _____.

a)

Remove top element

b)

Add element

c)

Check if empty

d)

Peek bottom

8.

When the stack has no elements, it is in _____ condition.

a)

Overflow

b)

Midflow

c)

Underflow

d)

Full

9.

When the stack is full and push is attempted, it causes _____.

a)

Underflow

b)

Overflow

c)

Error in code

d)

Reverse stack

10.

Static stack implementation uses _____.

a)

Linked list

b)

Graph

c)

Array

d)

Tree

11.

Dynamic stack implementation uses _____.

a)

Array

b)

Hashing

c)

Linked list

d)

Tree

12.

Static stacks have _____.

a)

Unlimited size

b)

Flexible size

c)

Fixed size

d)

Random size

13.

Dynamic stacks have _____.

a)

Fixed size

b)

Expandable/shrinkable size

c)

Non-resizable size

d)

Size limited by array

14.

In C++ static stack code, the initial value of top is _____.

a)

0

b)

1

c)

-1

d)

LIMIT

15.

The operation to check if stack is empty is named _____.

a)

isFull()

b)

isClear()

c)

isEmpty()

d)

top()

16.

In the code, stack overflow happens when:

a)

top == -1

b)

top == LIMIT

c)

top == LIMIT - 1

d)

top != LIMIT

17.

What does the peek() function return?

a)

Bottom element

b)

Middle element

c)

Top element

d)

Stack size

18.

The print order of display() function is _____.

a)

Bottom → Top

b)

Top → Bottom

c)

Random

d)

Every other element

19.

During pop, the code prints _____ before decreasing top.

a)

Stack size

b)

Popped element

c)

Entire stack

d)

Bottom element

20.

If top = 3 in a static stack, how many elements are inside?

a)

3

b)

4

c)

2

d)

1

21.

In the C++ STL stack, the function used to insert is _____.

a)

add()

b)

push()

c)

put()

d)

insert()

22.

In STL stack, the function to remove is _____.

a)

delete()

b)

erase()

c)

remove()

d)

pop()

23.

The STL function to check if the stack is empty is _____.

a)

isEmpty()

b)

empty()

c)

isempty()

d)

checkEmpty()

24.

The STL function to get stack size is _____.

a)

getSize()

b)

length()

c)

size()

d)

count()

25.

The STL function to access top is _____.

a)

peek()

b)

getTop()

c)

top()

d)

view()

26.

A stack is useful in implementing which of the following?

a)

BFS

b)

DFS

c)

Binary heaps

d)

Priority queue

27.

Stack overflow can be prevented by _____.

a)

Using dynamic memory

b)

Reducing RAM

c)

Using smaller data

d)

Using recursion

28.

In dynamic stack, push happens at _____ of linked list.

a)

Tail

b)

Middle

c)

Head

d)

Random pointer

29.

When pop is called on an empty stack, output is _____.

a)

Stack overflow

b)

Stack empty

c)

Stack underflow

d)

No change

30.

Which of the following best describes a stack?

a)

A dynamic queue

b)

A LIFO list

c)

A FIFO list

d)

A circular buffer

31.

A queue follows which principle?

a)

LIFO

b)

FIFO

c)

FILO

d)

Random order

32.

In a queue, insertion happens at the _____.

a)

Front

b)

Rear

c)

Middle

d)

Both ends

33.

In a queue, deletion happens at the _____.

a)

Rear

b)

Middle

c)

Front

d)

Random position

34.

Which end of the queue is used for adding elements?

a)

Bottom

b)

Head

c)

Rear

d)

Top

35.

Which end of the queue is used for removing elements?

a)

Rear

b)

Front

c)

Middle

d)

Tail

36.

Which operation adds an element to the queue?

a)

push

b)

insert

c)

enqueue

d)

addFront

37.

Which operation removes an element from the queue?

a)

pop

b)

dequeue

c)

extract

d)

removeLast

38.

Which operation shows the value at the front of the queue?

a)

top

b)

peak

c)

peek

d)

check

39.

A queue that has no elements is considered _____.

a)

Overflow

b)

Underflow

c)

Empty

d)

Broken

40.

Queue overflow happens when _____.

a)

rear == SIZE

b)

front == 0

c)

rear == SIZE - 1

d)

front == rear

41.

Underflow happens when dequeue is called but the queue is _____.

a)

Full

b)

Almost full

c)

Overflowing

d)

Empty

42.

In the C++ implementation, the initial value of front and rear is _____.

a)

0

b)

1

c)

-1

d)

SIZE

43.

After the first enqueue, what happens to front?

a)

It stays -1

b)

It becomes 1

c)

It becomes 0

d)

It becomes SIZE - 1

44.

Which of the following indicates an empty queue in the code?

a)

front == rear

b)

rear == SIZE

c)

front == -1 or front > rear

d)

rear == -1

45.

The function isFull() returns true when _____.

a)

front == rear

b)

rear == SIZE - 1

c)

front == 0

d)

front == SIZE

46.

In the queue array implementation, items are stored _____.

a)

From front backward

b)

From rear backward

c)

From index 0 upward

d)

Randomly

47.

What does peek() display if the queue is empty?

a)

0

b)

Undefined value

c)

“Queue is empty.”

d)

The last removed element

48.

What will happen if you enqueue into a full queue?

a)

Program stops

b)

Queue overflows

c)

Value overwrites old values

d)

Value goes to front

49.

In the sample code, after enqueue(10), enqueue(20), enqueue(30), the front element is ______.

a)

30

b)

20

c)

10

d)

Undefined

50.

When performing dequeue(), the operation removes the element at ______.

a)

front index

b)

rear index

c)

random index

d)

middle index

51.

The queue is full when there are how many elements in SIZE = 5?

a)

3

b)

4

c)

5

d)

6

52.

The condition (front > rear) means the queue is ______.

a)

Full

b)

Empty

c)

Overflow

d)

Reversed

53.

What is printed if dequeue is called but the queue is empty?

a)

Queue full

b)

Nothing

c)

Queue Underflow!

d)

Invalid operation

54.

To check if queue has no elements, we use ______.

a)

empty()

b)

isEmpty()

c)

length()

d)

none()

55.

Which statement is TRUE?

a)

Enqueue removes items

b)

Dequeue inserts items

c)

Peek removes the item

d)

Enqueue adds items

56.

Queues are commonly used in _____.

a)

Undo operations

b)

Browser history

c)

Scheduling processes

d)

Maze solving

57.

First element inserted in a queue is _____.

a)

Last removed

b)

Never removed

c)

Sometimes removed

d)

First removed

58.

Queue implementation with arrays is _____.

a)

Dynamic

b)

Static

c)

Circular always

d)

Linked-only

59.

Queues are also known as _____.

a)

LIFO structure

b)

FIFO structure

c)

FILO structure

d)

Random-access structure

60.

Sorting is the process of arranging elements in _____.

a)

Random order

b)

Ascending or descending order

c)

Zigzag order

d)

Grouped order

61.

Which of the following is NOT a type of sorting algorithm?

a)

Bubble sort

b)

Quick sort

c)

Merge sort

d)

Zigzag sort

62.

Which sorting algorithm is referred to as "Table sort" in the given options?

a)

Bubble sort

b)

Merge sort

c)

Selection sort

d)

Table sort

63.

Selection sort works by repeatedly finding the ______ value.

a)

Middle

b)

Maximum or minimum

c)

Random

d)

Second largest

64.

In selection sort, the minimum value is swapped with the value at the ______.

a)

Last position

b)

First position

c)

Middle position

d)

Random position

65.

In insertion sort, the array is divided into ______.

a)

Upper and lower halves

b)

Sorted and unsorted portions

c)

Even and odd sections

d)

Small and large values

66.

Insertion sort’s sorted portion initially contains ______.

a)

Two elements

b)

No elements

c)

One element

d)

Half of the array

67.

Insertion sort works by repeatedly ______.

a)

Placing each element into its proper position

b)

Swapping random elements

c)

Splitting the array into halves

d)

Using recursion

68.

In insertion sort, if the new element is smaller than the previous one, we ______.

a)

Delete it

b)

Move it to its correct position

c)

Swap it with the largest element

d)

Leave it unchanged

69.

Bubble sort repeatedly compares ______ elements.

a)

Elements 3 steps apart

b)

First and last elements

c)

Middle elements

d)

Adjacent elements

70.

Bubble sort gets its name because the largest value ______.

a)

Falls to the bottom

b)

Moves randomly

c)

Bubbles to the top (end of the array)

d)

Splits into halves

71.

In bubble sort, after the first full pass, the ______ is in its correct position.

a)

Smallest value

b)

Median value

c)

Largest value

d)

Random value

72.

Bubble sort requires ______ passes to fully sort an array.

a)

1

b)

Several

c)

None

d)

Infinite

73.

Which sorting algorithm uses repeated swapping of adjacent out-of-order elements?

a)

Bubble sort

b)

Quick sort

c)

Merge sort

d)

Shell sort

74.

Which sorting method is described as a “middle-of-the-road” choice for a few thousand items?

a)

Bubble sort

b)

Quick sort

c)

Insertion sort

d)

Merge sort

75.

According to the PDF, insertion sort is about _____ faster than selection sort.

a)

10%

b)

20%

c)

40%

d)

90%

76.

Selection sort performs how many swaps per pass?

a)

Many

b)

Unlimited

c)

Only one

d)

Zero

77.

Insertion sort searches for the correct position starting from _____.

a)

The end of the array

b)

The middle

c)

The beginning of the array

d)

Random locations

78.

Which sort is improved using a boolean flag to stop early if already sorted?

a)

Bubble sort

b)

Selection sort

c)

Heap sort

d)

Quick sort

79.

Bubble sort stops early when _____.

a)

Array is large

b)

Array is sorted

c)

Array is reversed

d)

Array is empty

80.

In the bubble sort example, only the _____ is correctly placed after the first pass.

a)

Two largest values

b)

Entire array

c)

Largest value

d)

Smallest value

81.

Which algorithm divides the array into sorted/unsorted sections?

a)

Selection sort

b)

Heap sort

c)

Insertion sort

d)

Shell sort

82.

Selection sort and bubble sort are both described as _____.

a)

Using recursion

b)

Similar in that both locate extreme values

c)

Using merge operations

d)

Fastest algorithms

83.

Bubble sort compares elements in _____ order.

a)

Reverse

b)

Diagonal

c)

Pairwise

d)

Clustered

84.

Example of insertion sort places array[2] into proper position so that array[0] ...array[2] becomes _____.

a)

Deleted

b)

Reversed

c)

Sorted

d)

Random

85.

The Boolean flag in bubble sort is used to detect _____.

a)

Overflow

b)

A swap is detected

c)

No swaps occur during a pass

d)

The flag is removed

86.

Selection sort repeatedly finds the _____ and moves it to the beginning.

a)

Maximum value

b)

Minimum value

c)

Middle value

d)

Average value

87.

In summary, insertion sort should NOT be used for lists larger than _____ items.

a)

10

b)

50

c)

A couple thousand

d)

A million

88.

Insertion sort is _____ faster than bubble sort according to the summary.

a)

Equal

b)

Twice as fast

c)

Half as fast

d)

Slightly slower

89.

Which of the following is a non-linear data structure?

a)

Array

b)

Stack

c)

Queue

d)

Tree

90.

Trees impose a _____ structure on a collection of items.

a)

Circular

b)

Hierarchical

c)

Linear

d)

Random

91.

Which of the following is an application of trees?

a)

Browser history

b)

Sorting completion

c)

Minimum value

d)

Recursion

92.

Which of the following is an example of a tree structure application?

a)

A. Sorting algorithms

b)

B. CPU scheduling

c)

C. Organization charts

d)

D. Hashing

93.

The root of a tree is the node that _____.

a)

A. Has no children

b)

B. Has no parent

c)

C. Is always a leaf

d)

D. Comes last

94.

A node in a tree stores _____.

a)

A. Arrays only

b)

B. Links only

c)

C. Data and links

d)

D. Functions

95.

The parent of a node is its _____.

a)

A. Leftmost child

b)

B. Root

c)

C. Immediate predecessor

d)

D. Sibling

96.

Nodes that share the same parent are called _____.

a)

A. Twins

b)

B. Leaves

c)

C. Siblings

d)

D. Ancestors

97.

A node with no children is called a _____.

a)

A. Parent

b)

B. Internal node

c)

C. Leaf / Terminal node

d)

D. Root

98.

The level of the root node is always _____.

a)

A. -1

b)

B. 1

c)

C. 0

d)

D. 2

99.

Depth of a node is defined as _____.

a)

The number of children

b)

The length of the path from the node to the leaf

c)

The length of the path from the root to the node

d)

The level minus one