Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
46ad053
Create READMEs for Fibonacci Heap and Threaded Binary Tree
jftung Mar 31, 2016
b7397f2
Add 'under construction' tags to Fib Heap and Thread Bin Tree
jftung Mar 31, 2016
d9fb909
Added Under Construction tags to ReadMe.md Files for Radix Sort, Coun…
Apr 1, 2016
16ec08f
Update ReadMe.md
Apr 1, 2016
484e8c1
Update ReadMe.md
Apr 1, 2016
f366732
Update ReadMe.md
Apr 1, 2016
9bf7a10
added constructing
Apr 6, 2016
8637316
Started Red Black Trees
Apr 7, 2016
9968b20
Delete redundant README
jftung Apr 8, 2016
adaf239
Link Threaded Binary Tree and Fib. Heap in README
jftung Apr 8, 2016
9e83965
Update ReadMe.md
Apr 8, 2016
e5b44de
Update ReadMe.md
Apr 8, 2016
8be3106
Update ReadMe.md
Apr 8, 2016
332530a
Update README construction tags
jftung Apr 10, 2016
ecb56e9
Fix README links
jftung Apr 10, 2016
d9681be
Add intro to Threaded Bin Tree README
jftung Apr 10, 2016
69e8c8f
Merge branch 'master' of github.com:axptwig/swift-algorithm-club
jftung Apr 10, 2016
1b48c5f
Add initial draft of ThreadBinTree traversal
jftung Apr 11, 2016
a13108a
Added Node class for Trie data structure
Apr 13, 2016
29aadb9
Merge branch 'master' of github.com:axptwig/swift-algorithm-club
Apr 13, 2016
3af9c37
Changed Character Typing to String Typing (Made more sense)
Apr 13, 2016
eb0d9f2
Updated Node class to be a bit cleaner and not as redundant. Started…
Apr 13, 2016
2eb7e9f
Begin converting BinarySearchTree.swift to ThreadedBinaryTree.swift
jftung Apr 23, 2016
ad134fd
Added debugged Insert and Find
Apr 28, 2016
05e402a
got rid of debugging statements
Apr 28, 2016
9dd86ba
Added a few functions for usage, working on remove
Apr 28, 2016
2e12fbe
Tweaked somethings
Apr 28, 2016
b879d55
Remove Fibonacci Heap
jftung Apr 28, 2016
07f3856
Bunch of stuff
Apr 28, 2016
3c98584
Remove Counting Sort
Apr 28, 2016
1d87ed1
Fixed Order of Deletion for Remove function in Trie class
Apr 28, 2016
f985b1b
Made some conditions more swift like
Apr 28, 2016
3ead1dd
Update RBTree.swift
Apr 29, 2016
7fc446a
Implemented print Trie, but encountered insert bug
Apr 29, 2016
6db3c7b
Merge branch 'master' of github.com:axptwig/swift-algorithm-club
Apr 29, 2016
16ee33f
Fixed a bug in the insert function
Apr 29, 2016
bd7398b
Fixed a bug where Remove was removing one node less than it should have.
Apr 29, 2016
8fe2ec2
Removed some debugging print statements
Apr 29, 2016
aa32c46
Added a merge function, still debugging findPrefix
May 2, 2016
6ec2d66
Finished Remove all, fixed a duplication error in constructor
May 2, 2016
8d0a20c
Got rid of unnecessary debugging print statements and variable declar…
May 2, 2016
006e74d
Add first draft of Threaded Binary Tree, with some images
jftung May 2, 2016
e22a42a
Merge branch 'master' of github.com:axptwig/swift-algorithm-club
jftung May 2, 2016
ac9abb4
Touch up ThreadedBinaryTree and begin testing
jftung May 3, 2016
0bf4008
Add traversal details to Threaded README
jftung May 3, 2016
7914569
Fix README link and delete unnecessary backup
jftung May 3, 2016
75a94e3
Finish threaded bin. tree images
jftung May 3, 2016
74f9ad5
Fix broken README links
jftung May 3, 2016
ab7bafa
Scrapped current findPrefix() implementation
May 3, 2016
461127f
Revamped directory structure to allow for importing of modules from i…
May 3, 2016
3d0bb6d
Finally got findPrefix() workinggit add .git add .!
May 3, 2016
002c70b
Fixed commit message....
May 3, 2016
6f88629
fixed insertion and rotations
May 3, 2016
c6d3403
Finalize ThreadedBinaryTree implementation
jftung May 3, 2016
692e49d
Merge branch 'master' of github.com:axptwig/swift-algorithm-club
jftung May 3, 2016
ba9b1bb
added delete helpers
May 4, 2016
df9e4f6
added predecessor
May 4, 2016
8fdc1af
Complete rough draft of Thread. Bin. Tree README
jftung May 4, 2016
6ab41aa
Finished Radix Sort Implementation
May 4, 2016
ab3f24a
Finalize Threaded Binary Tree README
jftung May 4, 2016
afde1e0
Merge branch 'master' of github.com:axptwig/swift-algorithm-club
jftung May 4, 2016
d13f9d0
Fix various typos in Threaded README
jftung May 4, 2016
6644f8b
added delete
May 4, 2016
ead1fc3
Update ReadMe.md
May 5, 2016
1a07781
Provided a temporary fix for insert function, finished radix sort rea…
May 5, 2016
7926986
I realized that I didnt actually push my changes......
May 5, 2016
9416c90
Update README.markdown
May 5, 2016
c26648b
Added something
May 5, 2016
95e2bf7
Merge branch 'master' of github.com:axptwig/swift-algorithm-club
May 5, 2016
1fb66f8
Update README.markdown
May 5, 2016
d0a7b19
Update README.markdown
May 5, 2016
764db27
deleted a print statement
May 5, 2016
6cbc877
Update ReadMe.md
May 5, 2016
79555bb
Update ReadMe.md
May 5, 2016
6dd9002
Update ReadMe.md
May 5, 2016
d0a7a6d
Update ReadMe.md
May 5, 2016
80f2611
Update ReadMe.md
May 5, 2016
285a1e9
Update ReadMe.md
May 5, 2016
833bae6
Readme Update
May 5, 2016
9c436cc
bug fixes + added figures to readme
May 5, 2016
23fede2
Delete RBTree.swift~
May 5, 2016
93dc8b9
Delete README.md~
May 5, 2016
9c44e70
Update README.md
May 5, 2016
97e93b6
Got rid of random build files
May 6, 2016
b66a88a
Merge branch 'master' of github.com:axptwig/swift-algorithm-club
May 6, 2016
d1874e8
Merged Queue with Trie
May 6, 2016
d6b6408
Got rid of build files
May 6, 2016
d5648e1
Update trie.swift
May 6, 2016
1649935
Remove unnecessary files
jftung May 6, 2016
a125a85
Got rid of binary
May 6, 2016
8c11c04
Merge branch 'master' of github.com:axptwig/swift-algorithm-club
May 6, 2016
ea555cc
Fixed a logic bug
May 6, 2016
6f9ef9b
Radix-Sort -> Radix Sort, Got rid of unnecessary ()'s in Trie
May 6, 2016
9857cb7
Renamed Red Black Trees -> Red-Black Tree
May 6, 2016
3aa88de
inline comments
May 6, 2016
610b532
Delete RBTree.swift~
May 6, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Radix Sort/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Radix Sort

Radix sort is a sorting algorithm that takes as input an array of integers and uses a sorting subroutine( that is often another efficient sorting algorith) to sort the integers by their radix, or rather their digit. Counting Sort, and Bucket Sort are often times used as the subroutine for Radix Sort.

##Example

* Input Array: [170, 45, 75, 90, 802, 24, 2, 66]
* Output Array (Sorted): [2, 24, 45, 66, 75, 90, 170, 802]

###Step 1:
The first step in this algorithm is to define the digit or rather the "base" or radix that we will use to sort.
For this example we will let radix = 10, since the integers we are working with in the example are of base 10.

###Step 2:
The next step is to simply iterate n times (where n is the number of digits in the largest integer in the input array), and upon each iteration perform a sorting subroutine on the current digit in question.

###Algorithm in Action

Let's take a look at our example input array.

The largest integer in our array is 802, and it has three digits (ones, tens, hundreds). So our algorithm will iterate three times whilst performing some sorting algorithm on the digits of each integer.

* Iteration 1: 170, 90, 802, 2, 24, 45, 75, 66
* Iteration 2: 802, 2, 24, 45, 66, 170, 75, 90
* Iteration 3: 2, 24, 45, 66, 75, 90, 170, 802



See also [Wikipedia](https://en.wikipedia.org/wiki/Radix_Sort).

*Written for the Swift Algorithm Club by Christian Encarnacion*
47 changes: 47 additions & 0 deletions Radix Sort/radixSort.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*

Sorting Algorithm that sorts an input array of integers digit by digit.

*/


func radixSort(inout arr: [Int] ) {


let radix = 10 //Here we define our radix to be 10
var done = false
var index: Int
var digit = 1 //Which digit are we on?


while !done { //While our sorting is not completed
done = true //Assume it is done for now

var buckets: [[Int]] = [] //Our sorting subroutine is bucket sort, so let us predefine our buckets

for _ in 1...radix {
buckets.append([])
}


for number in arr {
index = number / digit //Which bucket will we access?
buckets[index % radix].append(number)
if done && index > 0 { //If we arent done, continue to finish, otherwise we are done
done = false
}
}

var i = 0

for j in 0..<radix {
let bucket = buckets[j]
for number in bucket {
arr[i] = number
i += 1
}
}

digit *= radix //Move to the next digit
}
}
Loading