You are designing a system to store a large sparse matrix where memory usage is critical. Which approach is most suitable?
Use a standard 2D array.
Implement the sparse matrix using a hash table.
Store the matrix in a text file and read it when needed.
Use a dynamic array and resize it as needed.
Rotating an array by 'k' positions to the right means:
Shifting each element 'k' positions to the left.
Sorting the array in descending order.
Reversing the entire array.
Shifting each element 'k' positions to the right.
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 is not affected by the initial order of elements in the array.
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.
You need to rotate an array by a very large 'k'. What optimization can be applied to improve efficiency?
Sort the array before rotation.
No optimization is possible for large 'k'.
Use a temporary array to store elements.
Calculate the effective rotation (k % n) where n is the array length.
What is the main challenge in implementing a circular array?
Efficiently searching for elements in the array
Determining the starting index of the array
Managing the wrap-around behavior correctly
Handling the resizing of the array
Which of the following is NOT a valid approach for array rotation?
Merge Sort Algorithm
Block Swap Algorithm
Juggling Algorithm
Reversal Algorithm
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?
Staircase Search
Linear Search
Binary Search on each row
Breadth First Search
A dynamic array is used to store a growing dataset. When the array reaches its capacity and needs to resize, what is the common strategy to ensure amortized constant time complexity for appending elements?
Use a linked list instead of resizing the array.
Double the size of the array when full.
Create a new array with exactly the required size.
Increase the array size by a fixed constant when full.
What is the primary data structure used in Heap Sort?
Stack
Binary Heap
Queue
Linked List
What is the time complexity of resizing a dynamic array (like ArrayList in Java or vector in C++) when it becomes full?
O(1)
O(log n)
O(n)
O(n log n)