NEW
Font size
WorksheetsDSA Quiz - 50 Questions
Total questions: 50
Worksheet time: 25mins
What is the time complexity of accessing an element in an array using its index?
O(n)
O(log n)
O(1)
O(n log n)
Which of the following algorithms is best for finding the second largest element in an unsorted array?
Single traversal
Bubble Sort
Binary Search
Merge Sort
In string problems, which algorithm is used for pattern matching?
Kruskal's Algorithm
Rabin-Karp
Dijkstra's Algorithm
Prim's Algorithm
If an array is rotated k times, what is the best way to find the minimum element?
Linear search
Binary search
Hashing
Merge sort
What happens when you try to access an index that is out of bounds in an array?
Prints 5
IndexError
Prints None
Runtime Error
Which is not true about linked lists compared to arrays?
Easier insertion/deletion
Faster random access
Memory can be dynamic
Can grow/shrink easily
Which pointer makes a doubly linked list possible?
Next pointer only
Previous pointer only
Both next & previous
None
Application of circular linked list?
Undo operation
Memory management
Binary tree representation
Array storage
What will happen when you try to access data from a None head in a linked list?
Prints None
NullPointer Exception
Prints 0
No Error
Which is the most suitable data structure to implement a music playlist?
Stack
Queue
Circular Linked List
Array
Which is not an application of stack?
Function calls
Undo/Redo
Expression evaluation
Job Scheduling
If a stack has push() and pop(), then queue can be implemented using:
1 stack
2 stacks
3 stacks
None
Which data structure is used in Breadth First Search?
Stack
Queue
Tree
Heap
What happens when you try to pop from an empty stack?
Removes element
IndexError
Prints None
Runtime Warning
Which application uses priority queues?
CPU scheduling
Undo operation
BFS traversal
DFS traversal
What is the time complexity of searching in a balanced BST?
O(n)
O(1)
O(log n)
O(n log n)
Which traversal of a BST gives elements in sorted order?
Preorder
Postorder
Inorder
Level order
What is the maximum number of nodes in a binary tree of height h?
2^h - 1
h^2
log h
h!
Application of tries?
Sorting
Word Dictionary
Heap construction
Graph traversal
This condition checks for a leaf node in a binary tree.
Internal Node
Leaf Node
Root Node
Height
Which is not true about heaps?
Complete Binary Tree
Max element is at root (for max-heap)
Useful for heap sort
Provides O(1) search
Application of heaps?
Priority queue
Hashing
DFS traversal
Linked list
Hash collisions can be solved by:
Chaining
Deletion
DFS
BFS
In a max-heap of n elements, what is the complexity to insert an element?
O(n)
O(1)
O(log n)
O(n log n)
What is printed when you pop the smallest element from a heap?
5
2
1
3
Which algorithm is used to find the shortest path in a weighted graph?
Prim's
Kruskal's
Dijkstra's
DFS
Which algorithm is used for minimum spanning tree?
Dijkstra's
Kruskal's
BFS
DFS
Which data structure is used in DFS?
Stack
Queue
Linked List
Heap
This graph is directed cyclic.
Directed cyclic
Undirected
Acyclic
Tree
Which is an application of graph?
Maps & Navigation
CPU Scheduling
String reversal
Sorting numbers
Which is the fastest sorting algorithm on average?
Bubble sort
Quick sort
Selection sort
Insertion sort
Which sorting guarantees O(n log n) worst case?
Merge Sort
Quick Sort
Heap Sort
Bubble Sort
Binary search works only on:
Unsorted arrays
Linked Lists
Sorted arrays
Hash Tables
What is the best case complexity of Quick Sort?
O(n log n)
O(n)
O(n^2)
O(1)
What is printed when you check if an element is in an array?
Found
Error
Not Found
None
Which problem is solved by Dynamic Programming?
Traveling Salesman
Bubble Sort
Heap Sort
Binary Search
Coin Change problem uses:
Greedy always
DP always
DFS
Stack
Which is a greedy algorithm?
Kruskal's
Floyd-Warshall
Bellman-Ford
DP
This initializes DP array for Fibonacci.
Fibonacci
Sorting
DFS
Heap
Knapsack problem solved by greedy when:
0/1 Knapsack
Fractional Knapsack
Subset Sum
Graph coloring
Which is the best data structure for LRU cache?
Stack
LinkedList + HashMap
Queue
Tree
Huffman coding is used in:
Searching
Compression
Encryption
Graph traversal
Which traversal is used in topological sorting?
DFS
BFS
Inorder
Preorder
Which problem cannot be solved by greedy?
Minimum Spanning Tree
Fractional Knapsack
0/1 Knapsack
Job Scheduling
This code prevents infinite loops.
Infinite loop
Memory allocation
Stack overflow
Sorting
What's the complexity of BFS in a graph with V vertices and E edges?
O(V)
O(E)
O(V+E)
O(V*E)
Which is an amortized O(1) operation in arrays?
Insert at end
Insert at start
Delete middle
Binary Search
A red-black tree is a type of:
Balanced BST
Heap
Graph
Hash Table
In recursion, stack overflow occurs due to:
Too many nested calls
Too many loops
Large arrays
Linked lists
What is the output of the factorial function for 5?
0
120
24
Error
