What is the time complexity of resizing a dynamic array (like ArrayList in Java or vector in C++) when it becomes full?
O(n log n)
O(log n)
O(n)
O(1)
Merge Sort is considered a stable sorting algorithm. What does 'stable' mean in this context?
The algorithm uses a fixed amount of memory regardless of the input size.
The algorithm is not affected by the initial order of elements in the array.
The algorithm always takes the same amount of time to sort an array of a given size.
The algorithm maintains the relative order of elements with equal values after sorting.
You want to search for a target value in a sorted array with millions of elements. Which algorithm would generally be the fastest?
Interpolation Search
Jump Search
Binary Search
Linear Search
You are given a sorted array and a target value to insert. Which algorithm offers the best time complexity for inserting the target value while maintaining the sorted order?
Quick Sort
Bubble Sort
In merge sort, what is the maximum number of comparisons required to merge two sorted subarrays of size 'm' and 'n' into a single sorted array of size 'm+n'?
m + n
m * n - 1
m * n
m + n - 1
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?
Sparse array to handle potentially sparse data
Standard array with shifting elements on each insertion
Dynamic array (ArrayList, vector) to accommodate varying data sizes
Circular array to efficiently manage the fixed-size buffer
What is the time complexity of rotating an array of size 'n' by 'k' positions in place?
O(n*k)
O(k)
Which of the following algorithms guarantees finding the target element in a sorted array if it exists?
Both Linear Search and Binary Search
What is the time complexity of inserting an element into a Max Heap containing 'n' elements?
Interpolation search is most likely to outperform binary search when:
The array is unsorted.
The target element is located near the middle of the array.
The array is uniformly distributed.
The array size is small.