What is the time complexity of deleting a given value from an unsorted array in the worst case?
O(1)
O(log n)
O(n)
O(n log n)
You are designing a system to store a large sparse matrix where memory usage is critical. Which approach is most suitable?
Implement the sparse matrix using a hash table.
Use a dynamic array and resize it as needed.
Use a standard 2D array.
Store the matrix in a text file and read it when needed.
What is a key characteristic of a circular array?
It allows direct access to any element in O(1) time.
It automatically sorts elements in ascending order.
It conceptually wraps around, so the last element is followed by the first.
It has a fixed size that cannot be changed.
Merge Sort is considered a stable sorting algorithm. What does 'stable' mean in this context?
The algorithm maintains the relative order of elements with equal values after sorting.
The algorithm uses a fixed amount of memory regardless of the input size.
The algorithm always takes the same amount of time to sort an array of a given size.
The algorithm is not affected by the initial order of elements in the array.
In which scenario would using Insertion Sort for sorting an array be advantageous?
Sorting an almost sorted array.
Sorting an array with many duplicate elements.
Sorting a very large array.
Sorting an array in reverse order.
You need to rotate an array by a very large 'k'. What optimization can be applied to improve efficiency?
Use a temporary array to store elements.
Sort the array before rotation.
No optimization is possible for large 'k'.
Calculate the effective rotation (k % n) where n is the array length.
Which data structure is most suitable for implementing a sorted array with efficient insertion and deletion operations?
Linked List
Stack
Array
Queue
You need to implement a buffer that stores a fixed number of recent data points, discarding older data as new data arrives. Which array-based structure would be most appropriate?
Dynamic array (ArrayList, vector) to accommodate varying data sizes
Circular array to efficiently manage the fixed-size buffer
Sparse array to handle potentially sparse data
Standard array with shifting elements on each insertion
You are searching for a target value in a 2D matrix where each row and column is sorted in ascending order. Which search algorithm is the most efficient?
Breadth First Search
Linear Search
Binary Search on each row
Staircase Search
What data structure is commonly used to implement a sparse array efficiently?
Hash Table
Binary Tree