|
4 months ago | |
---|---|---|
src | 4 months ago | |
.gitignore | 4 months ago | |
LICENCE | 6 months ago | |
README.md | 4 months ago |
README.md
Sorting Algorithms
Collection of various sorting algorithms including serious ones that are actually good, but also funny ones like "RandomSort" or "SleepSort".
Template file
The file src/#Sort.kt acts as a template for new sorting algorithms. It includes a base setup with a main function and a sort function. The sort function needs to be implemented. The main function then firstly creates an array of size 10 with random numbers which will be sorted. For debugging purposes the result will be printed. Afterwards the speed of the algorithm will be tested. In a loop the algorithm is going to be called over and over but each time the size of the array gets bigger. A parameter called n is used to define the maximum array size. The measurements will be printed out during the tests
Example output
Before: [4, 8, 7, 0, 2, 7, 4, 7, 1, 3]
After: [0, 1, 2, 3, 4, 7, 7, 7, 7, 7]
Testing how long sorting takes for n elements.
| n | time |
|-------|-----------------------|
| 1 | 00m:00s:000ms:033us |
| 2 | 00m:00s:000ms:002us |
| 3 | 00m:00s:000ms:006us |
| 4 | 00m:00s:000ms:022us |
| 5 | 00m:00s:000ms:023us |
| 6 | 00m:00s:000ms:206us |
| 7 | 00m:00s:000ms:659us |
| 8 | 00m:00s:000ms:745us |
| 9 | 00m:00s:002ms:927us |
| 10 | 00m:00s:173ms:428us |