Insertion Sort can be considered an incremental algorithm. What does this mean?
It requires the entire dataset to be present in memory
It divides the problem into smaller subproblems
It performs better on smaller datasets
It can handle data arriving in a continuous stream
Why is understanding the time and space complexity of sorting algorithms crucial?
To determine the exact number of comparisons and swaps performed by an algorithm.
To predict the output of a sorting algorithm without actually executing it.
To convert between different sorting algorithms.
To estimate the efficiency and resource usage of an algorithm for different input sizes.
Sorting algorithms can be broadly classified into two categories. What are they?
In-place and Out-of-place
Recursive and Iterative
Stable and Unstable
Comparison-based and Non-comparison-based
What is the worst-case time complexity of Selection Sort?
O(n)
O(n log n)
O(n^2)
O(log n)
Bubble sort performs better than selection sort in which scenario?
When the input array is randomly ordered.
When the input array is already sorted.
When the input array is reversely sorted.
Bubble sort never outperforms Selection sort
Which sorting algorithm is generally considered more efficient for small datasets?
They have the same efficiency
Selection Sort
Bubble Sort
It depends on the data distribution
Which of the following is NOT a valid reason for using sorting algorithms?
Improving the performance of searching algorithms.
Compressing files for storage efficiency.
Presenting data in a user-friendly order.
Finding the median of a dataset.
What is the best-case time complexity of Insertion Sort?
O(1)
Is Selection Sort a stable sorting algorithm?
Yes
Only in its optimized version
No
Stability is irrelevant for Selection Sort
What is the space complexity of Bubble Sort in its standard form?