Algorithm in Python(1)

在计算机算法或数据结构类经典书籍中,用于算法描述语言的选择有两种情况,一种是选用“伪编程语言”,另外一种是选择C、C++或Java等“真实编程语言”。前者的例子是《 Introduction to Algorithm》,而后者的例子是《 Algorithm in C++》。(当然,有个变态老头用自己臆想的汇编语言来描述算法,居然还成了名著,这不是我们正常人可以讨论的)

采用伪语言,优点是简洁凝练,始终集中于算法本身,不受语言实现相关问题(如内存分配啦,类型系统啦)影响;相应的,其缺点是无法执行,对于读者或受教者来说缺乏直观感受及动手修改的可能。

采用C、C++或Java等“重型”编程语言(Sorry,Java fans!这里我把Java和C,C++相提并论,但它们确实太像了!),其优缺点正好与伪语言截然相反:长于可执行却短于不够简洁明了。

如果说有一种语言能取上述二者之优点并避其所短的话,那么我一定毫无私心地说,那就是Python!(嗯,我前面说过我是一个Pythoner了吧)Python具有类似伪语言的表达能力,同时又足够简单(没有C,C++中的动态内存分配和释放问题,也不受C、C++和Java中类型系统的拖累)。

某不才,想用Python来描述一系列经典的数据结构和算法,算是自娱吧。另外,作为“测试先行”理念的鼓吹者,所有的Unit Test代码也一并附上,至少能最小程度保证代码的可靠性吧。

我主要的参考书是《Algorithm in C++》。(其实我更喜欢《Introduction to Algorithm》,但是那页码也太恐怖了,背上它机动能力会降到0的)
  • 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、付费专栏及课程。

余额充值