r/CritiqueMyCode • • Nov 19 '14

[Java] Sortarithms: Inspired by that website Reddit crashed yesterday, I decided to write my first Java program. Sorting Algorithms!

https://github.com/eyabs/Sortarithms/blob/master/sortarithms.java
3 Upvotes

1 comment sorted by

1

u/eyabs Nov 19 '14

I wrote three sorting algorithms and compared their speed in sorting a randomly distributed list of 10000 doubles. I used quicksort3, selection sorting, and bubble sorting. Here's the results (time in microseconds):

Trial:	Bubble Sort:	Selection Sort:	QuickSort3:
1	930478		690793		4688
2	944337		741332		2241
3	942894		679924		2036
4	943714		680068		2038
5	928924		723855		2030
6	948854		676192		2022
7	938354		674978		2618
8	927880		681026		2078
9	1012793		674675		2017
10	938273		674935		2529
11	937794		675808		2018
12	1004513		673363		1947
13	949884		677920		1978
14	935031		690817		1904
15	1012142		673725		2006
16	934483		673889		2842
17	928870		675659		2078
18	930603		739696		2593
19	937837		686519		2052
20	934007		684235		1977
21	947086		750251		1973
22	946401		677436		2617
23	932522		674614		1992
24	942146		674845		1992
25	1005175		725065		2018