Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🐍 Algorithms

Actions status Code style: black

Well-known computer science algorithms published for practice and educational purposes.

Sorting

Bubble, selection and insertion sort algorithms were implemented to retrieve all iterations of their respective processes, instead of the sorted items.

Bubble

>>> bubble_sort([3, 2, 1])
[[3, 2, 1], [2, 3, 1], [2, 1, 3], [1, 2, 3]]
>>> bubble_sort([1, 2, 3], ascending=False)
[[1, 2, 3], [2, 1, 3], [2, 3, 1], [3, 2, 1]]

Selection

>>> selection_sort([3, 1, 2])
[[3, 1, 2], [1, 3, 2], [1, 2, 3]]
>>> selection_sort([2, 1, 3], ascending=False)
[[2, 1, 3], [3, 1, 2], [3, 2, 1]]

Insertion

>>> insertion_sort([3, 1, 2])
[[3, 1, 2], [1, 3, 2], [1, 2, 3]]
>>> insertion_sort([2, 1, 3], ascending=False)
[[2, 1, 3], [2, 3, 1], [3, 2, 1]]

Merge

Returns a list of tuples containing all merges performed.

>>> merge_sort([2, 3, 1])
[([3, 1], [1, 3]), ([2, 3, 1], [1, 2, 3])]
>>> merge_sort([2, 1, 3], ascending=False)
[([1, 3], [3, 1]), ([2, 1, 3], [3, 2, 1])]

About

Famous algorithms implemented in Python.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages