Python Algorithms Learning Notes(1)--Asymptotic Notations
来源:互联网 发布:plc编程功能块 编辑:程序博客网 时间:2024/06/06 00:00
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
- Write down the problem.
- Think real hard.
- 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 asO(g) ,Ω(g) andθ(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
For example,for a simple program like:
sum = 0for 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 ,
we leave out all the unimportant part of the formula for simplisity.
Below is the chart of common examples of asymptotic running Times , I think it’s really useful.
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
- The notes of Algorithms ---- Asymptotic Notation
- Python Algorithms Learning Notes(2)—Implementing Graphs and Trees
- Machine Learning Algorithms Study Notes
- Machine Learning Algorithms Study Notes--Supervised Learning
- Lecture 1: Introduction, complexity of algorithms, asymptotic growth of functions.
- Algorithms Notes (1)
- Machine Learning Algorithms Study Notes(4)—无监督学习(unsupervised learning)
- Python-learning-SMACH-Notes
- Python chapter 4 learning notes
- Python chapter 5 learning notes
- Python chapter 6 learning notes
- Python chapter 7 learning notes
- Python chapter 8 learning notes
- JSP Learning Notes 1
- Deep Learning Notes 1
- 【算法notes】Elementary Graph Algorithms 1
- Notes of Python Learning 2/10/2016
- 简单叙述服务端如何维护一个session
- 【Java并发编程】原子变量
- Java Swing:进度条字体颜色修改
- MySQL+DBUtils+C3P0+ Servlet+HTML完成Web端登陆验证案例实现
- 如何阅读caffe源码
- Python Algorithms Learning Notes(1)--Asymptotic Notations
- linux下pip使用可能遇到的问题
- C++多态,虚函数作用及底层实现原理
- Codeforces Round #426 (Div. 2) C:The Meaningless Game(思维)
- UVa12186 Another Crisis
- verilog中defparam的用法
- 欢迎使用CSDN-markdown编辑器
- ios-对图片进行裁剪得到一个新图片和保存到相册
- xynuoj (贪心) 积木大赛 酒馆浪人的博客