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 size is small.
The array is uniformly distributed.
You have a sorted array of 1000 elements. What is the maximum number of comparisons a binary search algorithm would need to find a target element or determine it's not present?
1000
500
100
10
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.
Double the size of the array when full.
Use a linked list instead of resizing the array.
Create a new array with exactly the required size.
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 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?
Binary Search
Quick Sort
Linear Search
Bubble Sort
You want to search for a target value in a sorted array with millions of elements. Which algorithm would generally be the fastest?
Jump Search
Interpolation Search
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(1)
O(n)
Merge Sort is considered a stable sorting algorithm. What does 'stable' mean in this context?
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.
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.
Which data structure is most suitable for implementing a sorted array with efficient insertion and deletion operations?
Stack
Linked List
Array
Queue
In which scenario would using Insertion Sort for sorting an array be advantageous?
Sorting a very large array.
Sorting an array in reverse order.
Sorting an array with many duplicate elements.
Sorting an almost sorted array.