You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+24-18Lines changed: 24 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,35 +2,41 @@
2
2
3
3
Visualizing sorting algorithms, using the matplotlib library.
4
4
5
-
Algorithms covered so far:<br />
6
-
Quick Sort<br />
7
-
Bubble Sort<br />
8
-
Selection Sort<br />
9
-
Insertion Sort<br />
10
-
Heap Sort<br />
11
-
Merge Sort
5
+
Algorithms covered so far:
6
+
7
+
| Name | Function Name |
8
+
| - |:-: |
9
+
| Quick Sort | quick_sort |
10
+
| Bubble Sort | bubble_sort |
11
+
| Selection Sort | selection_sort |
12
+
| Insertion Sort | insertion_sort |
13
+
| Heap Sort | heap_sort |
14
+
| Merge Sort | merge_sort |
12
15
13
16
# Usage:
14
17
18
+
Install
19
+
20
+
```pip install -r requirements.txt```
21
+
15
22
Run
16
23
17
24
```python main.py function_name```
18
25
19
-
Choose function name from list of functions above (in all lower case and spaces replaced by underscore).
26
+
Pass function name as a command line argument from list of functions above
27
+
(in all lower case and spaces replaced by underscore).
20
28
21
-
For example:
29
+
**For example:**
22
30
23
31
```python main.py quick_sort```
24
32
25
33
# How to contribute
26
34
27
-
Add new sorting algorithms to `sorting.py`
28
-
In your algorithms, pass an `Array` (defined in `sorting.py`) object, instead of a list.
29
-
30
-
The call to your sorting algorithm should be `sorting_algorithm(Array([1, 2, 3]))`, not `sorting_algorithm([1, 2, 3])`.
31
-
32
-
Whenever you are swapping values, call `Array.swap`, and whenever you are setting a value, call `Array.set`.
33
-
The length of the array can be found out using `Array.length`.
34
-
35
-
Make sure you test your newly implemented algorithm by running `test.py` after appending it to the list of algorithms in `test.py`.
35
+
**If you want to add a new sorting algorithm:**
36
36
37
+
1. Code the algorithm in ```sorting.py```.
38
+
2. Name the function appropriately, like ```quick_sort```, ```bubble_sort```.
39
+
3. While coding the function, **do not use python lists**. Instead, use an ```Array``` object. The ```Array``` class is defined in ```sorting.py```. (See already implemented algorithms, for your reference)
40
+
4. The ```Array``` object has ```swap```, ```set```, ```get_len```, ```get``` methods implemented. Feel free to implement any more, additional methods, that you may see fit.
41
+
5. Make sure you add the sorting algorithm to the Readme file!
42
+
6. Make sure your newly implemented algorithm works, by running `test.py` after appending it to the list of algorithms in `test.py`.
0 commit comments