2023-08-02 20:57:05 -07:00

50 lines
1009 B
Markdown

## sorting
<br>
* **inversions** in a sequence is a pair of elements that are out of order with respect to the ordering relation. a sorting algorithm is a sequence of operations that reduces inversions to zero.
* a **topological sort** of a diretect graph is a way of ordering the list of nodes such that if `(a, b)` is a edge of the graph, then `a` appears before `b`. it does not work if a graph has cycles or is not directed.
<br>
<p align="center">
<img src="https://github.com/go-outside-labs/master-algorithms-py/assets/138340846/7037aee5-9a83-4949-83df-e4c730debea4" width="60%" align="center" style="padding:1px;border:1px solid black;">
</p>
<br>
----
### some examples in this dir
<br>
#### `sorting_algorithms.py`
<br>
```python
> python3 sorting_algorithms.py
Array: [3, 5, 1, 2, 10, 6]
Testing merge sort: [1, 2, 3, 5, 6, 10]
Testing quick sort: [1, 2, 3, 5, 6, 10]
```
<br>
#### `binary_search.py`
<br>
```python
> python binary_search.py
Recursive: 6
Iterative: 6
```