Results 1 to 2 of 2
Thread: Learning Radix sort
- 03-01-2013, 03:20 AM #1
Member
- Join Date
- Mar 2013
- Posts
- 1
- Rep Power
- 0
Learning Radix sort
I understand how radix sort works. You take a set of numbers and your sort by the lowest part of each number. So if you have 345 236 and 786 you would sort by 1's position, 10's position, and 100's position. My book explains all this easily enough. It does not however give any explanation of how you about sorting a digit then the next and so on. I am writing a radix sort that uses counting sort as the stable sort and I am not completely sure how to maintain which digit position during sort. I have the counting sort working fine but I am not sure how to use the radix sort and then implement that into the counting sort
Java Code:public static int[] radixSort(int[] A, int d){ int[] B = new int[A.length]; int[] C = new int[d + 1]; for(int i = 0; i < d; i++){ for(int j = 0; j <= d; j++){ C[j] = 0; } for(int j = 0; j < A.length; j++){ C[A[j]] = C[A[j]] + 1; } for(int j = 1; j <= d; j++){ C[j] = C[j] + C[j-1]; } for(int j = A.length - 1; j >= 0; j--){ B[C[A[j]]-1] = A[j]; C[A[j]] = C[A[j]] - 1; } } return B; }
- 03-01-2013, 02:51 PM #2
Re: Learning Radix sort
Cross posted
java - Understanding Radix Sort - Stack Overflow
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Radix Sort
By Ronald Spina in forum New To JavaReplies: 2Last Post: 12-15-2012, 12:33 AM -
hi guys help me please . Learning from pdf is good or learning from book ?
By funkygarzon in forum New To JavaReplies: 12Last Post: 06-14-2011, 04:55 PM -
Parallel Radix Sorting client/server
By Darksurf in forum NetworkingReplies: 3Last Post: 04-29-2011, 07:07 AM -
Null Pointer Exception in Radix Sort
By resspopv in forum New To JavaReplies: 7Last Post: 11-19-2010, 05:21 AM -
Radix Sort Problem !!!!
By javanew in forum Advanced JavaReplies: 2Last Post: 09-21-2010, 04:33 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks