#snsdesignthinkers #snsinstitutions #designthinking
These algorithms do not rely on comparing elements directly but instead use properties of the data itself. They can achieve better time complexity than comparison-based algorithms in some cases.
- Concept: Counts the number of occurrences of each distinct element and uses this count to place each element in its correct position.
- Time Complexity: O(n + k) where n is the number of elements and k is the range of the numbers.
- Space Complexity: O(k) (requires additional space proportional to the range of numbers)
- Concept: Sorts numbers digit by digit, starting from the least significant digit to the most significant digit (or vice versa). It uses a stable sub-sorting algorithm like Counting Sort to sort the digits.
- Time Complexity: O(nk) where n is the number of elements and k is the number of digits.
- Space Complexity: O(n + k)
- Concept: Divides the range of values into k buckets, sorts each bucket individually (often using another sorting algorithm), and then concatenates the sorted buckets.
- Time Complexity: O(n + k) if the data is uniformly distributed and k is the number of buckets.
- Space Complexity: O(n + k)