Font size
WorksheetsQuiz-2
Total questions: 20
Worksheet time: 15mins
The time complexity of finding the maximum sum subarray using Kadane’s Algorithm is (a) .
You are given a sorted array and need to find if there exists a pair with sum equal to k. The best approach is:
Brute force with nested loops O(n²)
Sort and Binary Search O(n log n)
Two pointer approach O(n)
Hash map approach O(n)
The two pointer technique is most effective when the array is (a) .
Which of the following is NOT a valid use case of a hash map?
Counting frequency of elements
Checking duplicates in O(n)
Maintaining order of elements in O(1)
All the above
In Python, the hash map is implemented as a (a) data structure.
Given two strings s and t, check if they are anagrams. The most efficient approach uses:
Sorting both strings – O(n log n)
Hash map frequency count – O(n)
Brute force checking all permutations – O(n!)
Binary search on characters
To solve the Two Sum problem efficiently, we use a (a) to store visited numbers.
The time complexity of push and pop operations in a stack is (a) .
You are given an infix expression. Which of the following data structures is most suitable for converting it into postfix?
Queue
Stack
Hash Map
Linked List
The data structure used in the implementation of recursion in programming languages is (a) .
Which of the following allows efficient insertions and deletions at both ends but not random access?
Array
Linked List
Hash Map
Stack
In a singly linked list, each node contains data and a pointer to the (a) .
What is the time complexity of searching for an element in a singly linked list of size n?
O(1)
O(log n)
O(n)
O(n log n)
Can you detect a cycle in a linked list in O(n) time and O(1) space using Floyd’s Cycle Detection Algorithm (Tortoise and Hare method)?
True
False
You need to reverse a linked list in-place. What is the time and space complexity?
O(n), O(n)
O(n), O(1)
O(log n), O(1)
O(1), O(1)
To check if two strings are anagrams, which approaches are valid?
Sort both strings and compare
Compare frequency count of characters using hash map
Check if both strings are palindromes
Use XOR of all characters
Which problems can be solved efficiently using the two pointer technique?
Pair sum in sorted array
Trapping Rain Water
Reversing a linked list
Removing duplicates from sorted array
In sliding window or two pointer problems, what can pointers represent?
Left and right boundaries of a window
Fast and slow traversal speeds
Start and end of valid substring
Indices for recursion backtracking
Which of the following problems can be solved efficiently using hash maps?
Two Sum
Detecting cycle in linked list
Grouping anagrams
Finding subarray with given sum
Which statements are true about hash maps?
In Python, lists are implemented as hash maps
Average time complexity for lookup is O(1)
Worst case time complexity for lookup is O(n)
Collisions can be resolved using chaining
