我找到一个github标星75.5k+star的仓库,把各种常见算法用python实现了,而且还有动图演示,非常值得推荐。(黄海广)

仓库说明

这个仓库用python语言实现了绝大部分算法,主要是用于教学目的,因此效率稍微低于工业界。

仓库地址:https://github.com/TheAlgorithms/Python

内容说明

包含了常见的算法的python实现,如二叉树、排序、查找等等。这些是算法工程师必须掌握的技能。 

文件目录

常见算法的python实现(Github标星75.5k+)_github

常见算法的python实现(Github标星75.5k+)_python实现_02

冒泡排序

常见算法的python实现(Github标星75.5k+)_机器学习_03

桶排序

常见算法的python实现(Github标星75.5k+)_github_04

快速排序

排序典型代码(这个是冒泡排序的代码):

def bubble_sort(collection):
"""Pure implementation of bubble sort algorithm in Python


:param collection: some mutable ordered collection with heterogeneous
comparable items inside
:return: the same collection ordered by ascending


Examples:
>>> bubble_sort([0, 5, 2, 3, 2])
[0, 2, 2, 3, 5]


>>> bubble_sort([])
[]


>>> bubble_sort([-2, -45, -5])
[-45, -5, -2]


>>> bubble_sort([-23, 0, 6, -4, 34])
[-23, -4, 0, 6, 34]


>>> bubble_sort([-23, 0, 6, -4, 34]) == sorted([-23, 0, 6, -4, 34])
True
"""
length = len(collection)
for i in range(length - 1):
swapped = False
for j in range(length - 1 - i):
if collection[j] > collection[j + 1]:
swapped = True
collection[j], collection[j + 1] = collection[j + 1], collection[j]
if not swapped:
break # Stop iteration if the collection is sorted.
return collection




if __name__ == "__main__":
import time


user_input = input("Enter numbers separated by a comma:").strip()
unsorted = [int(item) for item in user_input.split(",")]
start = time.process_time()
print(*bubble_sort(unsorted), sep=",")
print(f"Processing time: {time.process_time() - start}")

总结

数据结构与算法设计怎么学?

免费的我推荐严蔚敏老师的数据结构课程,网上可以查到,用c语言实现,当年考博士时候学的就是这个。

收费的我推荐极客时间的《数据结构与算法之美》:http://gk.link/a/108GK ,内容挺全面,学了应该对算法有很大帮助。

算法的python实现推荐github上一个75.5k+star的仓库,把各种常见算法用python实现了,而且还有动图演示。

仓库地址:
​​​https://github.com/TheAlgorithms/Python​

如果网速太慢下载不下来,可以从我的百度云下载整站代码打包。

回复“20200605”获取下载地址。

常见算法的python实现(Github标星75.5k+)_机器学习_05



适合初学者入门人工智能的路线及资料下载机器学习及深度学习笔记等资料打印机器学习在线手册深度学习笔记专辑AI基础下载(pdf更新到25集)机器学习的数学基础专辑获取一折本站知识星球优惠券,复制链接直接打开:https://t.zsxq.com/yFQV7am本站qq群1003271085,加入微信群请扫码喜欢文章,点个在看