|
1 | 1 | # Sorting-algorithm
|
2 | 2 |
|
3 |
| -Sorting algorithms in Rust. |
| 3 | +Tested and Benchmarked Sorting algorithms in Rust. |
4 | 4 |
|
5 | 5 | ## Table of Contents
|
6 | 6 |
|
7 | 7 | - [Install](#install)
|
8 | 8 | - [Usage](#usage)
|
9 | 9 | - [Showcase](#showcase)
|
| 10 | +- [Supported Algoritms](#supported-algoritms) |
10 | 11 | - [Benchmarks](#benchmarks)
|
11 |
| -- [Instructions](#instructions) |
12 |
| -- [Supported Curves](#supported-curves) |
13 |
| -- [3rd party libraries used](#supported-curves) |
14 | 12 |
|
15 | 13 | ## Install
|
16 |
| - |
| 14 | +Clone and install this Github repository |
| 15 | +```git |
| 16 | +git clone https://github.com/johannes67890/Sorting-algorithm.git |
| 17 | +``` |
| 18 | +``` |
| 19 | +cargo install |
| 20 | +``` |
17 | 21 | ## Usage
|
| 22 | +```js |
| 23 | +// Run tests on functions |
| 24 | +> npm test |
18 | 25 |
|
19 |
| -## Benchmarks |
| 26 | +// Run benchmarks on functions |
| 27 | +> npm bench |
| 28 | +``` |
20 | 29 |
|
21 | 30 | ## Showcase
|
| 31 | +```rust |
| 32 | +/// Imported algorithm modules (See `Supported Algoritms`) |
| 33 | +mod bubble_sort; |
| 34 | +mod quick_sort; |
| 35 | + |
| 36 | +fn main(){ |
| 37 | + let mut arr = [6, 2, 4, 1, 9, -2, 5]; // array to sort |
22 | 38 |
|
| 39 | + // Bubble sort |
| 40 | + bubble_sort::bubblesort(&mut arr); // sort the array |
| 41 | + println!("Bubble sort: {:?}", arr); // print the sorted array |
| 42 | + |
| 43 | + // Quick sort |
| 44 | + quick_sort::quicksort(&mut arr); // sort the array |
| 45 | + println!("Quick sort: {:?}", arr); // print the sorted array |
| 46 | +} |
| 47 | +``` |
23 | 48 | ## Supported Algoritms
|
| 49 | +- Bubble Sort |
| 50 | +- Insertion Sort |
| 51 | +- Merge Sort |
| 52 | +- Quick Sort |
| 53 | +- Shell Sort |
| 54 | +## Benchmarks |
| 55 | +Line Chart of all supported algoritms from size 1 to 1000 element arrays |
| 56 | + |
| 57 | +## Individual Benchmarks (Size 100) |
| 58 | +Benchmarks of all sorting algorithms with size of array of 100 elements. |
| 59 | +#### Bubble Sort |
| 60 | +``` |
| 61 | +Sorting Algorithms/Bubble Sort/100 |
| 62 | + time: [8.1996 µs 8.2539 µs 8.3318 µs] |
| 63 | +Found 10 outliers among 100 measurements (10.00%) |
| 64 | + 1 (1.00%) high mild |
| 65 | + 9 (9.00%) high severe |
| 66 | +``` |
| 67 | +### Merge Sort |
| 68 | +``` |
| 69 | +Sorting Algorithms/Merge Sort/100 |
| 70 | + time: [12.033 µs 12.143 µs 12.277 µs] |
| 71 | +Found 17 outliers among 100 measurements (17.00%) |
| 72 | + 4 (4.00%) high mild |
| 73 | + 13 (13.00%) high severe |
| 74 | +``` |
| 75 | +### Insertion Sort |
| 76 | +``` |
| 77 | +Sorting Algorithms/Insertion Sort/100 |
| 78 | + time: [3.0122 µs 3.0183 µs 3.0256 µs] |
| 79 | +Found 7 outliers among 100 measurements (7.00%) |
| 80 | + 3 (3.00%) high mild |
| 81 | + 4 (4.00%) high severe |
| 82 | +``` |
| 83 | +### Quick Sort |
| 84 | +``` |
| 85 | +Sorting Algorithms/Quick Sort/100 |
| 86 | + time: [2.2028 µs 2.2116 µs 2.2222 µs] |
| 87 | +Found 10 outliers among 100 measurements (10.00%) |
| 88 | + 5 (5.00%) high mild |
| 89 | + 5 (5.00%) high severe |
| 90 | +``` |
| 91 | +### Shell Sort |
| 92 | +``` |
| 93 | +Sorting Algorithms/Shell Sort/100 |
| 94 | + time: [2.6537 µs 2.6644 µs 2.6769 µs] |
| 95 | +Found 10 outliers among 100 measurements (10.00%) |
| 96 | + 6 (6.00%) high mild |
| 97 | + 4 (4.00%) high severe |
| 98 | +``` |
| 99 | +# [Back to the top](#sorting-algorithm) |
0 commit comments