Lately , I’ve been reading《Python Algorithms》by Magnus Lie Hetland.
To understand the contents better , I’ll keep notes about it through the whole process.
It’s my first time to try to make notes in English only , hope I’ll make progress in both writing and algorithms after fininshing this book.

Here we go.
Today, I finished reading the first chapter and half of the chapter 2.

Chapter 1 Introduction

  1. Write down the problem.
  2. Think real hard.
  3. Write down the solution.
                     “The Feynman Algorithm”
                 as described by Murray Gell-Mann

For Chapter 1 , it’s introduction. This book seems to mainly focus on algorithms which are more high-level than those basic data structures like linked list. And I’m happy to know that many important concepts like sorting, searching and hashing are already available in Python or its standard libraries. Personally I feel I don’t have enough time to start from scratch ,so I’m quite satisfied with this book’s contents.

Chapter 2 The basics

Tracey: I didn’t know you were out there.
Zoe: Sort of the point. Stealth—you may have heard of it.
Tracey: I don’t think they covered that in basic.
            
              From “The Message,” episode 14 of Firefly

For Chapter 2, it tells the basic concepts and terminologies we need to know to describe and evalute an algorithm.

  • First problem is how we define “algorithm”?
    There is a very important concept —”Infinite State Machine”
    Infinite State Machine isn’t new to me ,I’ve learnt about it in several classes.These machines are simple yet surprisingly enough to implement any possible form of computation.
    Infinite State Machine is called Turing Machine , which enables us to depict all kinds of algorithm workflow in one model.
    With progress made in memories , the model is now called “Random Access Machine”,for we use big chunk of directly accessible memories now.

  • Now we have hardware we can run algorithms on ,the problem is how to note the problem .

A problem is a relation between input and output.
A relation (in the mathematical sense) is a set of pairs
In our case, which outputs are acceptable for which inputs.
By specifying this relation, we’ve got our problem nailed down.
The elements of input is problem instance , the relation is the actual problem

  • Asymptotic Notation
    To evaluate the performance of an algorithm , we have notions for running time complexity as O(g)O(g) , Ω(g)\Omega(g) and θ(g) \theta(g)
    The running time of an algorithm depends on two aspects: the size of input and the hardware condition.
    The “good” algorithms will increase at a reasonable rate when the input size grows . Considering the various hardware conditions, we choose a description system regardless of the hardware.
    We let the running time be the number of times a certain basic operation is performed

O(g)O(g) is actually the notation in calculus for high order infinetesiaml ,we use it to describe the upper bound of running time.

For example,for a simple program like:

sum = 0
for i in range(n)sum = sum + i

There are n times of addtions implemented inside the loop and one initialization step outside the loop ,so the running time is n+1 ,easy to see , n+1∈O(n)n+1 \in O(n) , so we say it complexity is O(n)O(n)
we leave out all the unimportant part of the formula for simplisity.

Ω(g)\Omega(g) is for lower bound
θ(g)\theta(g) . By supplying an upper bound and a lower bound at the same time, the operator is the most informative of the three.

Below is the chart of common examples of asymptotic running Times , I think it’s really useful.

Complexity Name Examples,Comments
θ(1)\theta(1) Constant Hash table lookup and modification
θ(lgn)\theta(\lg n) Logarithmic Binary search,Logarithm base unimportant.
θ(n)\theta(n) Linear Iterating over a list.
θ(nlgn)\theta(n\lg n) Loglinear Optimal sorting of arbitrary values Same as (lg n!).
θ(n2)\theta(n^2) Quadratic Comparing n objects to each other
θ(n3)\theta(n^3) Cubic Floyd and Warshall’s algorithms
θ(nk)\theta(n^k) Polynomial k nested for loops over n (if k is pos. integer). For any constant k > 0.
Ω(kn)\Omega(k^n) Exponential Producing every subset of n items (k = 2). Any k > 1.
θ(n!)\theta(n!) Factorial Producing every ordering of n values

That’s all for the first article , later on , I’ll learn about implementing graphs and trees.

I deeply realize how poor my English is writing this. Hope I’ll get better day by day.

Reference
《Python Algorithms》by Magnus Lie Hetland.

Python Algorithms Learning Notes(1)--Asymptotic Notations相关推荐

  1. Machine Learning Basics(2)

    文章目录 CODE WORKS CONTENTS Capacity, Overfitting and Underfitting The No Free Lunch Theorem Regulariza ...

  2. 参数匹配顺序——Python学习之参数(三)

    参数匹配顺序--Python学习之参数(三) 文章目录 参数匹配顺序--Python学习之参数(三) 函数参数匹配表 参数匹配顺序 keyword-only 参数的位置 参考资料 这篇博文是对上一篇博 ...

  3. 参数匹配模型——Python学习之参数(二)

    参数匹配模型--Python学习之参数(二) 文章目录 参数匹配模型--Python学习之参数(二) 位置参数:从左至右进行匹配 关键字参数:通过参数名进行匹配 默认参数:为没有传入值的参数定义参数值 ...

  4. Python学习之参数(一)

    Python学习之参数(一) 文章目录 Python学习之参数(一) 参数的传递 避免可变参数的修改 参考资料 参数的传递 所有的参数实际上都是通过指针进行传递的.作为参数被传递的对象从来不自动拷贝. ...

  5. 使用python制作ArcGIS插件(2)代码编写

    使用python制作ArcGIS插件(2)代码编写 by 李远祥 上一章节已经介绍了如何去搭建AddIn的界面,接下来要实现具体的功能,则到了具体的编程环节.由于使用的是python语言进行编程,则开 ...

  6. Machine Learning笔记(三) 多变量线性回归

    2019独角兽企业重金招聘Python工程师标准>>> Machine Learning笔记(三) 多变量线性回归 注:本文内容资源来自 Andrew Ng 在 Coursera上的 ...

  7. Python编曲实践(九):如何计算并估计音乐的调性(大/小调+主音)?Krumhansl-Schmuckler调性分析算法的原理与实现

    前言 之前,我在 Python编曲实践(五)中记录了构建MIDI数据集Free MIDI Library的过程,其中预处理阶段十分重要的一个步骤是移调,即把所有音乐的调性调整为C大调或A小调,这样会使 ...

  8. python常用扩展模块资源(大全)

    本文由 大侠(AhcaoZhu)整理并转载,转载请请引用原出处. 链接: https://blog.csdn.net/Ahcao2008 python常用扩展模块资源(大全) Python 资源大全中 ...

  9. 粗读《Python 深度学习》(4)

    粗读<Python 深度学习>(4) 第五章 深度学习用于计算机视觉 5.1 卷积神经网络简介 5.1.1 卷积运算 5.1.2 最大池化运算 5.2 在小型数据集上从头开始训练一个卷积神 ...

  10. Python数学建模系列(八):图论

    文章目录 前言 往期文章 1 图论模型 - Dijkstra 样例1 2 图论模型-Floyd 样例2 3 机场航线设计 0.Airlines.csv数据 1.数据导入.观察变量 2.数据清洗 3.时 ...

最新文章

  1. 清华大学第四届大数据开放日(Big Data Day)
  2. sqlserver数据库类型对应Java中的数据类型
  3. [云炬创业基础笔记]做好市场调研
  4. linux fedora35让GRUB 2记住上一次启动的操作系统
  5. 关于ArcMap中的地图文档单位
  6. CodeForces - 1358D The Best Vacation(前缀和+尺取)
  7. 回答网友提问:如何自学 SAP 电商云,销售云,营销云这些产品的业务知识?
  8. 9203精英挑战赛注意事宜 一
  9. 什么是隐形门? 隐形门安装要注意什么
  10. 22 副为程序员定制的对联,总有一副适合你...流泪
  11. Ruby+watir自动化测试中实现识别验证码图片
  12. Avoiding GREEDYDATA for logstash'grok
  13. python创建子窗口_python GUI编程(Tkinter) 创建子窗口及在窗口上用图片绘图实例
  14. AVL树,红黑树,B树,B+树,Trie树都分别应用在哪些现实场景中?
  15. java 开发常用工具下载
  16. SQL SERVER 2000数据库置疑处理
  17. Hough变换——检测直线
  18. CentOS 编译运行 DPDK 19.11 流程
  19. To iterate is human, to recurse, divine. — L. Peter Deutsch
  20. Opencv-获取两点之间距离

热门文章

  1. DSP2812之中断系统
  2. android 插件开发 过时,Android Sutdio ( Intelij ) 插件开发
  3. Mysql 数据库操作系统 官网 安装教程
  4. php开发oa系统的插件下载不了,什么是oa系统软件
  5. 家庭财务软件的概要分析
  6. guzzle 封装api_Wuzzlist API与Guzzle的速成课程
  7. 理解Android中的MeasureSpec
  8. 华为手机刷机后显示无服务器,华为手机刷机后,无法开机怎么办?
  9. PHP-Web聊天室 一天即可打造自己的聊天室-严双双-专题视频课程
  10. 视频编辑专家下载v9.3官方免费版