WorksheetsQuiz on Stack Data Structure
Total questions: 99
Worksheet time: 50mins
A stack follows which principle?
FIFO
LILO
LIFO
FILO
In a stack, insertion happens at the _____.
Middle
Bottom
Top
Random position
In a stack, deletion happens at the _____.
Middle
Bottom
Top
Random position
The bottom of the stack is the end where _____ happens.
Insertion
Deletion
No operations
Both insertion and deletion
Which one is NOT an application of stacks?
Undo operation
Back button of browser
Queue management
Reversing an array
Push means _____.
Remove an element
Add an element
Check size
Access bottom
Pop means _____.
Remove top element
Add element
Check if empty
Peek bottom
When the stack has no elements, it is in _____ condition.
Overflow
Midflow
Underflow
Full
When the stack is full and push is attempted, it causes _____.
Underflow
Overflow
Error in code
Reverse stack
Static stack implementation uses _____.
Linked list
Graph
Array
Tree
Dynamic stack implementation uses _____.
Array
Hashing
Linked list
Tree
Static stacks have _____.
Unlimited size
Flexible size
Fixed size
Random size
Dynamic stacks have _____.
Fixed size
Expandable/shrinkable size
Non-resizable size
Size limited by array
In C++ static stack code, the initial value of top is _____.
0
1
-1
LIMIT
The operation to check if stack is empty is named _____.
isFull()
isClear()
isEmpty()
top()
In the code, stack overflow happens when:
top == -1
top == LIMIT
top == LIMIT - 1
top != LIMIT
What does the peek() function return?
Bottom element
Middle element
Top element
Stack size
The print order of display() function is _____.
Bottom → Top
Top → Bottom
Random
Every other element
During pop, the code prints _____ before decreasing top.
Stack size
Popped element
Entire stack
Bottom element
If top = 3 in a static stack, how many elements are inside?
3
4
2
1
In the C++ STL stack, the function used to insert is _____.
add()
push()
put()
insert()
In STL stack, the function to remove is _____.
delete()
erase()
remove()
pop()
The STL function to check if the stack is empty is _____.
isEmpty()
empty()
isempty()
checkEmpty()
The STL function to get stack size is _____.
getSize()
length()
size()
count()
The STL function to access top is _____.
peek()
getTop()
top()
view()
A stack is useful in implementing which of the following?
BFS
DFS
Binary heaps
Priority queue
Stack overflow can be prevented by _____.
Using dynamic memory
Reducing RAM
Using smaller data
Using recursion
In dynamic stack, push happens at _____ of linked list.
Tail
Middle
Head
Random pointer
When pop is called on an empty stack, output is _____.
Stack overflow
Stack empty
Stack underflow
No change
Which of the following best describes a stack?
A dynamic queue
A LIFO list
A FIFO list
A circular buffer
A queue follows which principle?
LIFO
FIFO
FILO
Random order
In a queue, insertion happens at the _____.
Front
Rear
Middle
Both ends
In a queue, deletion happens at the _____.
Rear
Middle
Front
Random position
Which end of the queue is used for adding elements?
Bottom
Head
Rear
Top
Which end of the queue is used for removing elements?
Rear
Front
Middle
Tail
Which operation adds an element to the queue?
push
insert
enqueue
addFront
Which operation removes an element from the queue?
pop
dequeue
extract
removeLast
Which operation shows the value at the front of the queue?
top
peak
peek
check
A queue that has no elements is considered _____.
Overflow
Underflow
Empty
Broken
Queue overflow happens when _____.
rear == SIZE
front == 0
rear == SIZE - 1
front == rear
Underflow happens when dequeue is called but the queue is _____.
Full
Almost full
Overflowing
Empty
In the C++ implementation, the initial value of front and rear is _____.
0
1
-1
SIZE
After the first enqueue, what happens to front?
It stays -1
It becomes 1
It becomes 0
It becomes SIZE - 1
Which of the following indicates an empty queue in the code?
front == rear
rear == SIZE
front == -1 or front > rear
rear == -1
The function isFull() returns true when _____.
front == rear
rear == SIZE - 1
front == 0
front == SIZE
In the queue array implementation, items are stored _____.
From front backward
From rear backward
From index 0 upward
Randomly
What does peek() display if the queue is empty?
0
Undefined value
“Queue is empty.”
The last removed element
What will happen if you enqueue into a full queue?
Program stops
Queue overflows
Value overwrites old values
Value goes to front
In the sample code, after enqueue(10), enqueue(20), enqueue(30), the front element is ______.
30
20
10
Undefined
When performing dequeue(), the operation removes the element at ______.
front index
rear index
random index
middle index
The queue is full when there are how many elements in SIZE = 5?
3
4
5
6
The condition (front > rear) means the queue is ______.
Full
Empty
Overflow
Reversed
What is printed if dequeue is called but the queue is empty?
Queue full
Nothing
Queue Underflow!
Invalid operation
To check if queue has no elements, we use ______.
empty()
isEmpty()
length()
none()
Which statement is TRUE?
Enqueue removes items
Dequeue inserts items
Peek removes the item
Enqueue adds items
Queues are commonly used in _____.
Undo operations
Browser history
Scheduling processes
Maze solving
First element inserted in a queue is _____.
Last removed
Never removed
Sometimes removed
First removed
Queue implementation with arrays is _____.
Dynamic
Static
Circular always
Linked-only
Queues are also known as _____.
LIFO structure
FIFO structure
FILO structure
Random-access structure
Sorting is the process of arranging elements in _____.
Random order
Ascending or descending order
Zigzag order
Grouped order
Which of the following is NOT a type of sorting algorithm?
Bubble sort
Quick sort
Merge sort
Zigzag sort
Which sorting algorithm is referred to as "Table sort" in the given options?
Bubble sort
Merge sort
Selection sort
Table sort
Selection sort works by repeatedly finding the ______ value.
Middle
Maximum or minimum
Random
Second largest
In selection sort, the minimum value is swapped with the value at the ______.
Last position
First position
Middle position
Random position
In insertion sort, the array is divided into ______.
Upper and lower halves
Sorted and unsorted portions
Even and odd sections
Small and large values
Insertion sort’s sorted portion initially contains ______.
Two elements
No elements
One element
Half of the array
Insertion sort works by repeatedly ______.
Placing each element into its proper position
Swapping random elements
Splitting the array into halves
Using recursion
In insertion sort, if the new element is smaller than the previous one, we ______.
Delete it
Move it to its correct position
Swap it with the largest element
Leave it unchanged
Bubble sort repeatedly compares ______ elements.
Elements 3 steps apart
First and last elements
Middle elements
Adjacent elements
Bubble sort gets its name because the largest value ______.
Falls to the bottom
Moves randomly
Bubbles to the top (end of the array)
Splits into halves
In bubble sort, after the first full pass, the ______ is in its correct position.
Smallest value
Median value
Largest value
Random value
Bubble sort requires ______ passes to fully sort an array.
1
Several
None
Infinite
Which sorting algorithm uses repeated swapping of adjacent out-of-order elements?
Bubble sort
Quick sort
Merge sort
Shell sort
Which sorting method is described as a “middle-of-the-road” choice for a few thousand items?
Bubble sort
Quick sort
Insertion sort
Merge sort
According to the PDF, insertion sort is about _____ faster than selection sort.
10%
20%
40%
90%
Selection sort performs how many swaps per pass?
Many
Unlimited
Only one
Zero
Insertion sort searches for the correct position starting from _____.
The end of the array
The middle
The beginning of the array
Random locations
Which sort is improved using a boolean flag to stop early if already sorted?
Bubble sort
Selection sort
Heap sort
Quick sort
Bubble sort stops early when _____.
Array is large
Array is sorted
Array is reversed
Array is empty
In the bubble sort example, only the _____ is correctly placed after the first pass.
Two largest values
Entire array
Largest value
Smallest value
Which algorithm divides the array into sorted/unsorted sections?
Selection sort
Heap sort
Insertion sort
Shell sort
Selection sort and bubble sort are both described as _____.
Using recursion
Similar in that both locate extreme values
Using merge operations
Fastest algorithms
Bubble sort compares elements in _____ order.
Reverse
Diagonal
Pairwise
Clustered
Example of insertion sort places array[2] into proper position so that array[0] ...array[2] becomes _____.
Deleted
Reversed
Sorted
Random
The Boolean flag in bubble sort is used to detect _____.
Overflow
A swap is detected
No swaps occur during a pass
The flag is removed
Selection sort repeatedly finds the _____ and moves it to the beginning.
Maximum value
Minimum value
Middle value
Average value
In summary, insertion sort should NOT be used for lists larger than _____ items.
10
50
A couple thousand
A million
Insertion sort is _____ faster than bubble sort according to the summary.
Equal
Twice as fast
Half as fast
Slightly slower
Which of the following is a non-linear data structure?
Array
Stack
Queue
Tree
Trees impose a _____ structure on a collection of items.
Circular
Hierarchical
Linear
Random
Which of the following is an application of trees?
Browser history
Sorting completion
Minimum value
Recursion
Which of the following is an example of a tree structure application?
A. Sorting algorithms
B. CPU scheduling
C. Organization charts
D. Hashing
The root of a tree is the node that _____.
A. Has no children
B. Has no parent
C. Is always a leaf
D. Comes last
A node in a tree stores _____.
A. Arrays only
B. Links only
C. Data and links
D. Functions
The parent of a node is its _____.
A. Leftmost child
B. Root
C. Immediate predecessor
D. Sibling
Nodes that share the same parent are called _____.
A. Twins
B. Leaves
C. Siblings
D. Ancestors
A node with no children is called a _____.
A. Parent
B. Internal node
C. Leaf / Terminal node
D. Root
The level of the root node is always _____.
A. -1
B. 1
C. 0
D. 2
Depth of a node is defined as _____.
The number of children
The length of the path from the node to the leaf
The length of the path from the root to the node
The level minus one
