Which of the following is a real-world application of sorting in databases?
Natural language processing for text analysis.
Query optimization for faster retrieval of results.
Data compression for efficient storage.
Data encryption for enhanced security.
Insertion Sort can be considered an incremental algorithm. What does this mean?
It performs better on smaller datasets
It can handle data arriving in a continuous stream
It divides the problem into smaller subproblems
It requires the entire dataset to be present in memory
What is the worst-case space complexity of Insertion Sort?
O(n)
O(1)
O(n log n)
O(log n)
What is the best-case time complexity of Insertion Sort?
O(n^2)
Sorting algorithms can be broadly classified into two categories. What are they?
Comparison-based and Non-comparison-based
In-place and Out-of-place
Stable and Unstable
Recursive and Iterative
What is the fundamental difference between comparison-based and non-comparison-based sorting algorithms?
Comparison-based algorithms are more memory efficient than non-comparison-based algorithms.
Comparison-based algorithms are faster than non-comparison-based algorithms.
Comparison-based algorithms are used for numerical data, while non-comparison-based algorithms are used for text data.
Comparison-based algorithms sort by comparing elements, while non-comparison-based algorithms exploit data properties for sorting.
When does Insertion Sort exhibit its worst-case time complexity?
When the array has a random distribution of elements
When the array is reverse sorted
When all elements in the array are the same
When the array is already sorted
Why are sorting algorithms considered fundamental in computer science?
They are only used in specific niche applications.
They are rarely used in modern software development.
They are primarily used for displaying data to the user.
They are the basis for more complex algorithms and data structures.
Which of the following is a real-world analogy for how Insertion Sort works?
Finding a book in a library by its Dewey Decimal number
Arranging cards in a hand by suit and rank
Searching for a specific webpage on the internet
Shuffling a deck of cards
What is a key limitation of both Bubble Sort and Selection Sort?
They are inefficient for large datasets
They are not stable sorting algorithms
They have a high space complexity
They cannot handle arrays with duplicate elements