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 log n)
O(n)
You are designing a system to store a large sparse matrix where memory usage is critical. Which approach is most suitable?
Store the matrix in a text file and read it when needed.
Implement the sparse matrix using a hash table.
Use a standard 2D array.
Use a dynamic array and resize it as needed.
Which of the following is NOT a valid approach for array rotation?
Block Swap Algorithm
Juggling Algorithm
Reversal Algorithm
Merge Sort Algorithm
Which of the following statements is TRUE about Quick Sort?
It is generally preferred over Merge Sort for arrays.
It performs poorly on already sorted arrays if the pivot selection is not optimized.
It is a stable sorting algorithm.
It always has a time complexity of O(n log n).
What is the time complexity of searching for a target value in a sorted array using binary 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?
Increase the array size by a fixed constant when full.
Create a new array with exactly the required size.
Double the size of the array when full.
Use a linked list instead of resizing the array.
In which scenario is a sparse array particularly useful?
Representing a matrix with mostly zero values
Storing a large sorted array
Implementing a stack data structure
Storing a small array with frequent updates
Quick Sort is generally considered faster than Merge Sort in practice. What is one of the main reasons for this?
Quick Sort is a stable sorting algorithm, while Merge Sort is not.
Quick Sort typically has smaller constant factors in its time complexity.
Quick Sort has better time complexity in all cases.
Quick Sort has better space complexity than Merge Sort.
Which data structure is most suitable for implementing a sorted array with efficient insertion and deletion operations?
Array
Linked List
Stack
Queue
You want to search for a target value in a sorted array with millions of elements. Which algorithm would generally be the fastest?
Binary Search
Interpolation Search
Jump Search
Linear Search