algorithms-Python3中数据结构和算法的最小示例实现


  

测试

使用单元测试

要运行所有测试,请写:

$ python3 -m unittest discover tests

对于运行某些特定的测试,您可以按照以下步骤进行操作(例如:sort):

$ python3 -m unittest tests.test_sort

使用pytest

要运行所有测试,请写下:

$ python3 -m pytest tests

安装

如果要在代码中使用API算法,则非常简单:

$ pip3 install algorithms

您也可以下载algorithms的库文件包手动安装。

您可以通过创建python文件进行测试:(例如:merge_sort在中使用sort)

from algorithms.sort import merge_sort
if __name__ == "__main__":    
    my_list = [1, 8, 3, 5, 6]    
    my_list = merge_sort(my_list)    
    print(my_list)

卸载

如果要卸载algorithms,它很简单:

$ pip3 uninstall -y algorithms

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
本书用Python语言来讲解算法的分析和设计 分别介绍了树、图、计数问题、归纳递归、遍历、分解合并、贪心算法、复杂依赖、Dijkstra算法、匹配切割问题以及困难问题及其稀释等内容 Python Algorithms explains the Python approach to algorithm analysis and design. Written by Magnus Lie Hetland, author of Beginning Python, this book is sharply focused on classical algorithms, but it also gives a solid understanding of fundamental algorithmic problem-solving techniques. * The book deals with some of the most important and challenging areas of programming and computer science, but in a highly pedagogic and readable manner. * The book covers both algorithmic theory and programming practice, demonstrating how theory is reflected in real Python programs. * Well-known algorithms and data structures that are built into the Python language are explained, and the user is shown how to implement and evaluate others himself. What you'll learn * Transform new problems to well-known algorithmic problems with efficient solutions, or show that the problems belong to classes of problems thought not to be efficiently solvable. * Analyze algorithms and Python programs both using mathematical tools and basic experiments and benchmarks. * Prove correctness, optimality, or bounds on approximation error for Python programs and their underlying algorithms. * Understand several classical algorithms and data structures in depth, and be able to implement these efficiently in Python. * Design and implement new algorithms for new problems, using time-tested design principles and techniques. * Speed up implementations, using a plethora of tools for high-performance computing in Python. Who this book is for The book is intended for Python programmers who need to learn about algorithmic problem-solving, or who need a refresher. Students of computer science, or similar programming-related topics, such as bioinformatics, may also find the book to be quite useful. Table of Contents * Introduction * The Basics * Counting 101 * Induction and Recursion ...and Reduction * Traversal: The Skeleton Key of Algorithmics * Divide, Combine, and Conquer * Greed Is Good? Prove It! * Tangled Dependencies and Memoization * From A to B with Edsger and Friends * Matchings, Cuts, and Flows * Hard Problems and (Limited) Sloppiness

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值