推荐算法第三方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中的线程与线程池)
- python 并发传输文件(python单线程文件传输的实例C/S)
- python 游戏开发实例(python实现诗歌游戏类继承)
- python起源详解(Python发展简史 Python来历)
- python类定义(浅谈python新式类和旧式类区别)
- python给一个数字md5加密(Python写一个基于MD5的文件监听程序)
- python获取excelsheet名称(python查询文件夹下excel的sheet名代码实例)
- python删除数据框重复变量(Python3删除排序数组中重复项的方法分析)
- python中的pandas功能(Python常见的pandas用法demo示例)
- 使用python编辑个人名片(python实现名片管理系统项目)
- pythonmatplotlib条形图动画(Python Matplotlib实现三维数据的散点图绘制)
- python 操作html(Python HTML解析模块HTMLParser用法分析爬虫工具)
- python使用aes加密解密(python实现AES和RSA加解密的方法)
- python爬虫开源代码(Python实现的文轩网爬虫完整示例)
- pythonredis列表(Python redis操作实例分析连接、管道、发布和订阅等)
- python字典的值排序(python 对字典按照value进行排序的方法)
- 三杨 共辅四朝帝王,构建明帝国内阁行政圈(三杨共辅四朝帝王)
- 红色文化进国企(红色文化进国企)
- 车友的选择| 轮毂该如何选(车友的选择轮毂该如何选)
- 秦海璐炫耀和王新军热恋蜜事,不料对方吐槽她吃饱后肚子撅老高(秦海璐炫耀和王新军热恋蜜事)
- 秦海璐一袭旗袍惹人倾心,将高级与淡雅展现的游刃有余(秦海璐一袭旗袍惹人倾心)
- 门外之见 海蛎子味 的表演,能走多远(门外之见海蛎子味)
热门推荐
- SQL语句中单引号
- sql server占cpu高
- mysql中timestamp类型的CURRENT_TIMESTAMP 和ON UPDATE CURRENT_TIMESTAMP属性
- vue获取图片并展示(vue卡片式点击切换图片组件使用详解)
- 异步调用中HttpContext.Current为null解决方法
- VS不生成.vhost.exe和.pdb文件
- mysql自增锁(深入剖析 MySQL 自增锁)
- vue-router的两种模式(vue-route路由管理的安装与配置方法)
- python基本数据结构(浅谈Python编程中3个常用的数据结构和算法)
- 阿里云盘8月永久激活码(再分享6个可无限激活阿里云盘邀请码,不信你不能激活阿里云盘)
排行榜
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9