WorksheetsData Structures and Algorithms Quiz
Total questions: 70
Worksheet time: 53mins
What is an Abstract Data Type (ADT)?
A specific implementation of a data structure
A mathematical model for data types, specifying operations but not implementation
Any user-defined type in programming
A physical device used for storing data
Which of the following best describes an ADT?
Defines only data storage
Describes both data and allowed operations without implementation
Specifies physical storage
Specifies algorithm efficiency
Which is NOT a feature of an ADT?
Data representation is hidden
Specifies operation set
Specifies hardware for storage
Defines type's behavior
Which operation is essential for stack ADT?
dequeue
insert at start
push
find min
In an algorithm, which property ensures it eventually completes?
Finiteness
Input
Output
Definiteness
Which term describes the rules to perform tasks in an algorithm?
Abstraction
Instruction
Step
Procedure
Which of the following is a property of a good algorithm?
Ambiguous steps
High time complexity
Finiteness
Infinite loops
Algorithm analysis deals primarily with:
Code syntax
Correctness and efficiency
Code documentation
Data input methods
Time complexity measures:
Disk space used
Maximum number of steps for a given input
Amount of output
Code length
Space complexity measures:
Running time
Storage required
Speed of processor
Number of operators in code
Big O notation describes:
Best-case complexity
Worst-case upper bound
Average-case only
Space complexity only
Big Omega (Ω) notation expresses:
Minimum time algorithm takes in the worst case
Lower bound time complexity
Space usage only
Compiled code size
Big Theta (Θ) denotes:
The tightest lower bound
The tightest upper bound
The exact asymptotic bound
Best-case only
f(n) = O(g(n)) means:
f(n) grows faster than g(n)
g(n) is an upper bound for f(n)
f(n) equals g(n) for all n
None
If f(n) = Θ(g(n)), then:
f(n) grows slower than g(n)
f(n) and g(n) grow at the same rate
f(n) is always less than g(n)
g(n) is a lower bound for f(n)
The notation O(1) denotes:
Constant time complexity
Linear time complexity
Quadratic time
Exponential time
Which notation is used to describe the best-case of an algorithm?
O()
Ω()
Θ()
None
Which asymptotic notation signifies the lower bound?
Big O
Big Theta
Big Omega
Small o
If an algorithm has time complexity O(n²), what happens as input size doubles?
Time remains same
Time quadruples
Time halves
Time doubles
For f(n) = 5n + 20, what is the Big O complexity?
O(1)
O(n)
O(n²)
O(log n)
What defines time complexity?
Amount of time algorithm takes to run
Amount of memory used
Number of variables declared
Code length
Which has higher time complexity?
O(n)
O(n²)
O(log n)
O(1)
Which function grows fastest as n increases?
log n
n
n²
n log n
O(log n) efficiency is commonly found in:
Linear search
Binary search
Bubble sort
Selection sort
What is the time complexity of iterating through all elements in a list of size n?
O(1)
O(n)
O(n²)
O(log n)
If an algorithm doubles its steps with each input added, time complexity is:
O(1)
O(n)
O(n²)
O(2ⁿ)
Which of these has the least time complexity?
O(1)
O(log n)
O(n)
O(n²)
An algorithm uses an array of n elements and a constant number of variables. What is its space complexity?
O(1)
O(n)
O(n²)
O(log n)
For recursive algorithms, space complexity includes:
Only input size
Only call stack
Call stack plus all variables
None
Which affects space complexity?
Number of function calls
Use of auxiliary data structures
Size of input data
All of the above
A stack is a:
FIFO structure
LIFO structure
Random access
Tree
Which operation removes top from stack?
Push
Pop
Pick
Insert
Which operation adds to stack?
InsertFirst
Push
Dequeue
Remove
The element inserted last in stack is:
Removed first
Never removed
Removed at last
None
What happens when attempting to pop from an empty stack?
Stack overflow
Stack underflow
No effect
Program restarts
Which is not a stack operation?
Enqueue
Push
Pop
Peek
Peek operation in stack:
Returns and removes top element
Returns but does not remove top element
Removes but does not return top element
None
Stack can be implemented by:
Array
Linked list
Either A or B
Tree
Which application uses stack?
Expression evaluation
Recursion tracking
Undo in editors
All of the above
The initial value of top in an empty stack (array implementation) is:
0
1
-1
None
Applications of Stack: Infix to Postfix, Expression Evaluation, Towers of Hanoi
Queue implementation
Infix to postfix conversion
Tree traversals only
None
Infix expression A+B is converted to postfix as:
AB+
+AB
AB
B+A
The main advantage of postfix notation is:
Difficult computation
No need for parentheses
Needs more space
More time-consuming
Which data structure is used for expression evaluation?
Queue
Stack
Array
Heap
How many stacks are needed for evaluating a postfix expression?
1
2
3
4
What is the postfix of the expression (A+B)C?
ABC+*
AB+C*
+ABC*
None
The number of moves required to solve Tower of Hanoi with n disks is:
n
n²
2ⁿ-1
n!
In Tower of Hanoi, to move n disks, the recursive solution:
Is not feasible
Moves n-1 disks, then nth disk
Does not use stack
Ignores recursive calls
Which data structure is mirrored in recursion?
Queue
Stack
Array
Heap
Which structure is used by compilers to implement function calls?
Queue
Stack
Heap
Array
A queue is:
LIFO
FIFO
FILO
None
Which queue operation inserts an element?
Push
PoP
Enqueue
Peek
Which operation removes the front element?
push
pop
dequeue
remove
Which queue operation checks the element at the front without removing?
Front
Rear
Empty
Insert
Initial state of front and rear in an empty queue (array) is:
0, 0
-1, -1
1, 1
Null
A queue can be implemented using:
Stack
Array
Linked List
B or C
In queue, insertion takes place at:
Rear
Front
Middle
Top
Which is NOT an application of queues?
Job scheduling
Printing tasks
Function call management
Breadth First Search
Queue overflow occurs when:
Removing element from empty queue
Adding element to full queue
Both A and B
None
If front = rear in a queue with n elements, the queue is:
Empty
Full
Not Defined
None of the above
Circular Queue overcomes which problem of regular queues?
Underflow
Wasted space due to space unavailability at front
Overflow
Duplicates allowed
In circular queue, front = (front + 1) % size removes element from:
Front
Rear
Random
top
Deque allows insertions and deletions at:
Rear only
Front only
Both ends
Middle only
Which operation is not allowed in a simple queue?
Enqueue at rear
Dequeue at rear
Dequeue at front
Enqueue at rear
Which is a real-life application of circular queue?
CPU Scheduling
Browser History
Expression Evaluation
Recursion
In circular queue, what condition for overflow if rear is at the last position?
rear == front
(rear+1)%size == front
rear == size
None
Which of the following is NOT a queue type?
Priority Queue
Simple Queue
Circular Queue
Binary Queue
Deque stands for:
Double-ended queue
Data-ended queue
Dual queue
Data enqueue
What is a Queue Underflow?
Queue is full
Queue is empty and a delete operation is tried
Queue exists but not full
Both Queue is full and Queue exists but not full
Which operation can add element at front of deque?
enqueueFront
enqueueRear
dequeueFront
dequeueRear
