Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
32 views9 pages

RadixSortingGSA G1

Uploaded by

wuwadummy55
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views9 pages

RadixSortingGSA G1

Uploaded by

wuwadummy55
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Radix

Sorting
PREPARED BY:

ABREGANA, MARC ANDREI


AGUI,CHARLES KLINT
VALDEZ, LIPO
VILLARUEL, ROLLY
VILLANUEVA, GENER
What is radix sorting?

Radix, in the context of data structures, refers to the base of a


number system and is a fundamental concept in understanding
Radix Sort, a non-comparative sorting algorithm. This method
sorts data by processing individual digits of numbers or
characters, making it efficient for specific use cases such as
sorting integers or strings.
History of
Radix
The concept of radix has roots in mathematics,
originating from number theory, where it signifies
the base of a positional numeral system. The
application of radix in sorting emerged in the mid-
20th century when researchers sought faster
sorting techniques beyond comparison-based
methods. Donald Knuth's "The Art of Computer
Programming" detailed the use of Radix Sort as a
practical sorting technique.
Evolution of Radix

Radix Sort has evolved significantly since its inception.


Initially used for card sorting in the 19th century, its
application expanded with the advent of digital computers.
The algorithm progressed from simple digit-by-digit
processing to optimized implementations, like the Least
Significant Digit (LSD) and Most Significant Digit (MSD)
approaches, tailored for different datasets and architectures.
Algorithm
(Two-Way Explanation)

Intuitive Steps
1. Find the maximum number in the array to determine the number of digits.
2. Sort the array digit by digit, starting from the least significant digit (LSD) to the
most significant digit (MSD).
3. Use a stable sorting algorithm like Counting Sort for each digit to maintain the
order of elements with the same digit value.
4. Repeat until all digits are processed.
Java Implementation

public static void radixSort(int[] arr) {


int max = Arrays.stream(arr).max().getAsInt();
int exp = 1;
for (int i = 1; i < 10; i++) {
count[i] += count[i - 1];
while (max / exp > 0) {
}
countingSort(arr, exp);
exp *= 10;
for (int i = n - 1; i >= 0; i--) {
}
int index = (arr[i] / exp) % 10;
}
output[count[index] - 1] = arr[i];
count[index]--;
private static void countingSort(int[] arr, int exp) {
}
int n = arr.length;
int[] output = new int[n];
for (int i = 0; i < n; i++) {
int[] count = new int[10];
arr[i] = output[i];
}
for (int i = 0; i < n; i++) {
}
int index = (arr[i] / exp) % 10;
count[index]++;
}
Big-O Notation and Time
Complexity
The time complexity of Radix Sort is
Radix Sort's complexity depends on
calculated by multiplying the
the number of digits (d) and the
number of elements (n). Its Big-O number of digits (d) with the
Notation is: number of elements (n):
Best Case: O(n × d) Sorting per digit: O(n)
Average Case: O(n × d) Total passes (digits): O(d)
Worst Case: O(n × d)
Thus, the total time complexity is
Radix Sort performs well when d is
O(n × d). This is better than
small relative to n, making it
efficient for datasets with fixed- comparison-based sorts like Merge
length keys. Sort or Quick Sort (O(n log n)) for
specific datasets.
THANK YOU FOR LISTENING!

You might also like