推荐算法第三方python(GitHub 热门:Python 算法大全,Star 超过 2 万)
类别:脚本大全 浏览量:1946
时间:2021-10-12 00:25:29 推荐算法第三方python
GitHub 热门:Python 算法大全,Star 超过 2 万4 月 27 日,github 趋势榜第 3 位是一个用 python 编码实现的算法库,star 数早已达到 26000+
链接:https://github.com/thealgorithms/python
这个库涵盖了多种算法和数据结构的介绍,比如:
- 排序算法(冒泡排序、希尔排序、插入排序、桶排序、合并排序、快速排序、堆排序、选择排序等)、
- 查找算法(线性查找、二分查找、插值查找等)
- 加密算法(凯撒加密、rsa、rot13 等)
- 机器学习
- 图
- 数字图像处理
- 动态规划
- 常见数据结构(队列、栈、链表、树等)
这个库虽然包括的种类很多,但内容其实分了 2 方面:① 算法的原理简介;② 算法的代码实现;
比如:冒泡算法的 python 实现
|
from __future__ import print_function 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, 3, 2, 2]) [0, 2, 2, 3, 5] >>> bubble_sort([]) [] >>> bubble_sort([-2, -5, -45]) [-45, -5, -2] >>> bubble_sort([-23,0,6,-4,34]) [-23,-4,0,6,34] """ 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__' : try : raw_input # python 2 except nameerror: raw_input = input # python 3 user_input = raw_input ( 'enter numbers separated by a comma:' ).strip() unsorted = [ int (item) for item in user_input.split( ',' )] print ( * bubble_sort(unsorted), sep = ',' ) |
感兴趣的童鞋,请收藏:
https://github.com/thealgorithms/python
好了,就给大家介绍到这里吧,希望大家喜欢!
原文链接:https://blog.51cto.com/14304496/2385783
您可能感兴趣
- python核心编程和python基础教程(从0开始的Python学习014面向对象编程推荐)
- python 装饰器模式(python重试装饰器的简单实现方法)
- python完整异常机制(深入理解Python异常处理的哲学)
- python 导入指定文件夹的模块(Python实现的在特定目录下导入模块功能分析)
- python入门练习网页(详解python项目实战:模拟登陆CSDN)
- python随机生成时间戳(python时间序列按频率生成日期的方法)
- python获取系统的utc时间(Python的UTC时间转换讲解)
- python做了一个自动翻译的小工具(Python 20行简单实现有道在线翻译的详解)
- python turtle简易绘图(详解Python使用Plotly绘图工具,绘制甘特图)
- python时间类的实现(Python日期时间Time模块实例详解)
- python复杂的验证码处理(Python 通过打码平台实现验证码的实现)
- python中生成字符串序列(python实现字符串加密 生成唯一固定长度字符串)
- python爬取豆瓣评分排行榜(Python爬虫——爬取豆瓣电影Top250代码实例)
- python编写端口扫描器(Python开发网站目录扫描器的实现)
- python怎么转换jar包(利用python脚本如何简化jar操作命令)
- python2.7中logging的使用方式(Python中使用logging和traceback模块记录日志和跟踪异常)
- 吉善缘《聚宝金蟾》金蟾招财摆件 三足全铜蟾蜍客厅店铺开业礼品(吉善缘聚宝金蟾金蟾招财摆件)
- 招财化煞神兽,金蟾变了(招财化煞神兽金蟾变了)
- 26岁杨紫的白素贞遇上24岁鞠婧祎,哪个最美(26岁杨紫的白素贞遇上24岁鞠婧祎)
- 鞠婧祎和杨紫两种风格的女生,你心里谁比较美(鞠婧祎和杨紫两种风格的女生)
- 三千年第一美女鞠婧祎出演白素贞pk杨紫,颜值胜赵雅芝王祖贤(三千年第一美女鞠婧祎出演白素贞pk杨紫)
- 成都轨道交通13号线一期工程最新进展(成都轨道交通13号线一期工程最新进展)
热门推荐
- CSS font-family
- jsforeach语句(JS面试题之forEach能否跳出循环详解)
- python正则表达式入门(Python正则表达式实现简易计算器功能示例)
- 面试时如何谈自己的缺点
- nginx如何配置php项目(Nginx服务器究竟是怎么执行PHP项目)
- python ssh登录服务器(python利用跳板机ssh远程连接redis的方法)
- windowsserver如何安装iis(windows Server2012 IIS8.0配置安装完整教程)
- sqlserver厉害的函数(SQL Server里书签查找的性能伤害)
- sql查看数据库所有表名(SQL提取数据库表名及字段名等信息代码示例)
- php100种算法(php实现的生成排列算法示例)
排行榜
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9