Sunday, May 22, 2016

Radix Sort - a distribution sort

May 22, 2016

Read the blog, have some code using C# in short future:


C# practice based on the above blog:
comment: Line 47, change array name from int[] count -> int[] position, but still get confused; This variable does more than one task. 
https://gist.github.com/jianminchen/ba73ca1550b88eae99c1617c1636180d
Make some changes:
Change the array's name to helper, helper serves three functions (line 47): 
1. First, get count for each digit
2. Second, add sum from 0 to up 
3. Third, decrease one by one to track index of next available position for i. 
comment: Line 47, change array name to helper, and add comment to list tasks for helper. Feel more control, there is a term called "express the intent." 
https://gist.github.com/jianminchen/09f12e539fce1b267e75d808e13c4ff6
Prepare for Leetcode 164: Maximum Gap 

No comments:

Post a Comment