NEW
Font size
S
M
L
XL
WorksheetsDSA Quiz
Total questions: 30
Worksheet time: 15mins
Name
Class
Date
1.
What is the primary importance of choosing the right data structure in software development?
a)
To make code look more professional
b)
To optimize time and space complexity for specific operations
c)
To follow coding standards
d)
To reduce the number of lines of code
2.
What is the time complexity of accessing an element in an array by index?
a)
O(n)
b)
O(log n)
c)
O(1)
d)
O(n²)
3.
In Big-O notation, what does O(log n) typically represent?
a)
Linear time complexity
b)
Quadratic time complexity
c)
Logarithmic time complexity (like binary search)
d)
Constant time complexity
4.
What is the main advantage of a 2D array over multiple 1D arrays?
a)
Uses less memory
b)
Provides better cache locality and represents matrix-like data naturally
c)
Easier to implement
d)
Faster access time
5.
What is the time complexity of inserting an element at the beginning of a linked list?
a)
O(n)
b)
O(log n)
c)
O(1)
d)
O(n²)
6.
In hashing, what is the primary purpose of a hash function?
a)
To encrypt data
b)
To map keys to array indices for fast retrieval
c)
To sort data
d)
To compress data
7.
Which operation is NOT typically supported by a stack?
a)
Push
b)
POP
c)
Peek/Top
d)
Random access by index
8.
What is the main difference between a stack and a queue?
a)
Stack uses more memory
b)
Stack is LIFO (Last In First Out), Queue is FIFO (First In First Out)
c)
Queue is faster than stack
d)
Stack can only store integers
9.
What is the main advantage of linked lists over arrays?
a)
Faster access to elements
b)
Dynamic size and efficient insertion/deletion at any position
c)
Uses less memory
d)
Better cache performance
10.
. Which collision resolution technique involves storing multiple values in the same hash table slot using a secondary data structure?
a)
Linear probing
b)
Quadratic probing
c)
Chaining
d)
Double hashing
11.
In a binary tree, what is the maximum number of nodes at level 'k'?
a)
K
b)
2^k
c)
2^(k-1)
d)
k²
12.
What property must a Binary Search Tree (BST) satisfy?
a)
All nodes must have exactly two children
b)
Left subtree values ≤ root ≤ right subtree values
c)
The tree must be complete
d)
All leaf nodes must be at the same level
13.
What is the average time complexity of search, insert, and delete operations in a balanced BST?
a)
O(n)
b)
O(log n)
c)
O(1)
d)
O(n²)
14.
Which traversal technique does BFS (Breadth-First Search) use?
a)
Stack
b)
Queue
c)
Recursion only
d)
Array
15.
What data structure does DFS (Depth-First Search) typically use?
a)
Queue
b)
Stack (or recursion)
c)
Array
d)
Hash Table
16.
In graph theory, what is the difference between a directed and undirected graph?
a)
Directed graphs have more nodes
b)
In directed graphs, edges have direction; in undirected graphs, edges are bidirectional
c)
Undirected graphs are faster to traverse
d)
Directed graphs use more memory
17.
What is the time complexity of Dijkstra's algorithm using a binary heap?
a)
O(V²)
b)
O((V + E) log V)
c)
O(VE)
d)
O(E log E)
18.
What is the main difference between Dijkstra's algorithm and A* algorithm?
a)
A* uses a heuristic function to guide the search
b)
Dijkstra's is faster
c)
A* only works on directed graphs
d)
Dijkstra's uses more memory
19.
What is the time complexity of linear search in an unsorted array?
a)
O(n)
b)
O(log n)
c)
O(1)
d)
O(n²)
20.
What is the prerequisite for binary search to work correctly?
a)
Array must be of even size
b)
Array must be sorted
c)
Array must contain unique elements
d)
Array must be stored in linked list
21.
What is the time complexity of bubble sort in the worst case?
a)
O(n)
b)
O(n log n)
c)
O(n²)
d)
O(log n)
22.
Which sorting algorithm has the best average-case time complexity?
a)
Bubble sort
b)
Insertion sort
c)
Selection sort
d)
Merge sort
23.
What is the space complexity of merge sort?
a)
O(1)
b)
O(log n)
c)
O(n)
d)
O(n²)
24.
Which sorting algorithm is most efficient for small datasets or nearly sorted arrays?
a)
Quick sort
b)
Merge sort
c)
Insertion sort
d)
Heap sort
25.
What is the worst-case time complexity of quick sort?
a)
O(n log n)
b)
O(n²)
c)
O(n)
d)
O(log n)
26.
In heap sort, what type of data structure is used?
a)
Binary Search Tree
b)
Complete Binary Tree (Heap)
c)
Linked List
d)
Hash Table
27.
What is the load factor in hashing?
a)
The number of collisions
b)
The ratio of number of elements to the size of hash table
c)
The size of the hash table
d)
The number of hash functions used
28.
In the context of graph algorithms, what does "weighted graph" mean?
a)
The graph has more nodes than edges
b)
Each edge has an associated numerical value (weight)
c)
The graph is stored using adjacency matrix
d)
The graph has cycles
29.
What is the primary advantage of using adjacency list over adjacency matrix for sparse graphs?
a)
Faster edge lookup
b)
Better space efficiency
c)
Easier to implement
d)
Supports weighted edges better
30.
In a complete binary tree with n nodes, what is the height of the tree?
a)
log₂(n)
b)
⌊log₂(n)⌋
c)
n/2
d)
n-1
Reset
