1 / 99

Algorithms Design and its Applications

Algorithms Design and its Applications. Introduction. Something about me. 刘晓铭 Home Page: http://sist.sysu.edu.cn/~isslxm Email: isslxm@mail.sysu.edu.cn Office: 信息学院楼 526B. Something about this course. Course homepage: http://sist.sysu.edu.cn/~isslxm/ada/cs2013/index.html

arty
Télécharger la présentation

Algorithms Design and its Applications

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Algorithms Design and its Applications Introduction

  2. Something about me 刘晓铭 • Home Page: http://sist.sysu.edu.cn/~isslxm • Email: isslxm@mail.sysu.edu.cn • Office: 信息学院楼526B

  3. Something about this course • Course homepage:http://sist.sysu.edu.cn/~isslxm/ada/cs2013/index.html • BBS: http://bbs.sysu.edu.cn/bbsdoc?board=ACMICPC • Office Hours:每周一下午2:00 – 4:00,信息学院楼526B其它时间可邮件预约。

  4. Something about this course • 1. 平时作业:在线编程练习+书面作业http://soj.me/ • 2. 研究型的小Project :选一个问题,编程实现解决这一问题的若干种算法,在不同规模的测试数据上,比较各种算法的性能 • 3. 期末考试:ACM 方式机试, 自动测评

  5. FAQ • Q: 这门课是为了培养参加ACM / ICPC比赛的队员而专门开设的吗? • A: No. Some important topics not included in ICPC • Advanced Algorithm Analysis Techniques • NP-Completeness Proofs • Randomized and Approximation Algorithms • Quantum Algorithms

  6. 推荐教材

  7. 武林秘籍

  8. Why take this course?

  9. You want to be a computer scientist?

  10. Is your goal to be a mundane programmer?

  11. Or a great leader and thinker?

  12. Original Thinking

  13. Boss assigns task: • Given today’s prices of pork, grain, sawdust, … • Given constraints on what constitutes a hotdog. • Make the cheapest hotdog. Everyday industry asks these questions.

  14. Your answer: • Um? Tell me what to code. With more sophisticated software engineering systems,the demand for mundane programmers will diminish.

  15. Your answer: • I learned this great algorithm that will work. Soon all known algorithms will be available in libraries.

  16. Your answer: • I can develop a new algorithm for you. Great thinkers will always be needed.

  17. Course Content • A list of algorithms. • Learn their code. • Trace them until you are convinced that they work. • Implement them. • Worry about details. class InsertionSortAlgorithm extends SortAlgorithm { void sort(int a[]) throws Exception { for (inti = 1; i < a.length; i++) { int j = i; int B = a[i]; while ((j > 0) && (a[j-1] > B)) { a[j] = a[j-1]; j--;} a[j] = B; } }

  18. Course Content • A survey of algorithmic design techniques. • Abstract thinking. • How to develop new algorithms for any problem that may arise.

  19. Study: • Many experienced programmers were asked to code up binary search.

  20. Study: • Many experienced programmers were asked to code up binary search. 80% got it wrong

  21. What did they lack?

  22. What did they lack? • Formal proof methods?

  23. What did they lack? • Formal proof methods? Yes, likely Industry is starting to realize that formal methods are important. But even without formal methods …. ?

  24. What did they lack? • Fundamental understanding of the algorithmic design techniques. • Abstract thinking.

  25. Course Content Notations, analogies, and abstractions for developing, thinking about, and describing algorithms so correctness is transparent

  26. A survey of fundamental ideas and algorithmic design techniques For example . . .

  27. Logic Quantifiers Logs and Exps g "b Loves(b,g)"b g Loves(b,g) 2a× 2b = 2a+b2log n = n Time Classifying Functions Time Complexity f(i) = nQ(n) t(n) = Q(n2) Input Size Adding Made Easy Recurrence Relations ∑i=1 f(i). T(n) = a T(n/b) + f(n) Some Math

  28. 0 i-1 i T+1 i i 5 km 9 km Iterative Algorithms Loop Invariants <preCond> codeA loop <loop-invariant> exit when <exit Cond> codeB codeC <postCond> One step at a time Code Relay Race

  29. Recursive Algorithms

  30. Recursive Back Tracking

  31. Greedy Algorithms

  32. 2 8 9 5 8 4 4 6 2 3 5 7 5 6 1 3 2 5 4 8 Dynamic Programing 4 5 3 2

  33. Graph Search Algorithms

  34. Network Flows

  35. Reduction = • Rudich www.discretemath.com

  36. Useful Learning Techniques

  37. Read Ahead You are expected to read the lecture notesbefore the lecture. This will facilitate more productive discussionduringclass. Also please proof readassignments & tests.

  38. Be Creative Ask questions. Why is it done this way and not thatway?

  39. Please feel free to ask questions! Help me know what people are not understanding Slow down the slides We do have a lot of material Please don’t shout out answersfor at least 10sec.

  40. What is algorithm? Informally, an algorithm is any well – defined computational procedure that takes some value, or set of values, as input and produces some value, or set of values, as output . --Introduction to Algorithms

  41. Sorting Problem Input: A sequence of n keys a1, a2, …, an. Output: The permutation of the input sequence such that a1’≤a2’≤…≤an’. • An instance (实例):Inpute: <31, 41, 59, 26, 41, 58>Output: <26, 31, 41, 41, 58, 59>

  42. 如果对每个输入的实例,算法都能正确的停机,则称该算法是正确的。如果对每个输入的实例,算法都能正确的停机,则称该算法是正确的。 • 不正确的算法对某些输入实例可能根本不停机,也可能以不正确的输出停机。 • 不正确的算法只要错误率可控有时可能是有用的。例如,大素数的判定。

  43. Knuth said Knuth (1968, 1973) has given a list of five properties that are widely accepted as requirements for an algorithm: Finiteness: "An algorithm must always terminate after a finite number of steps ... a very finite number, a reasonable number" Definiteness: "Each step of an algorithm must be precisely defined; the actions to be carried out must be rigorously and unambiguously specified for each case" Input: "...quantities which are given to it initially before the algorithm begins. These inputs are taken from specified sets of objects" Output: "...quantities which have a specified relation to the inputs" Effectiveness: "... all of the operations to be performed in the algorithm must be sufficiently basic that they can in principle be done exactly and in a finite length of time by a man using paper and pencil"

  44. Finally … The word algorithm does not have a generally accepted definition. From wikipedia

  45. Analysis of algorithms • The theoretical study of computer-program performance and resource usage. • What’s more important than performance? • modularity • correctness • maintainability • functionality • robustness • user-friendliness • programmer time • simplicity • extensibility • reliability

  46. 为什么学习算法 原因之一:广泛的应用 • Human Genome Project • Internet • Electronic commerce security • Other manufacturing and commercial setting • Etc.

  47. 为什么学习算法 原因之二:强大的力量 排序n个项,插入排序,c1n2归并排序,c2n lgn n=1000万 计算机A: 较快,每秒执行百亿条指令,执行插入排序,实现较好,代码需要2n2条指令。 计算机B: 较慢,每秒执行1000万条指令,执行归并排序,实现较差,代码需要50nlgn条指令。 计算机A: 2*(107)2条指令/1010条指令每秒=20000秒 计算机B: 50*107lg107条指令/107条指令每秒=1163秒 计算机B比计算机A还快17倍!

  48. 为什么学习算法 不懂算法的悲剧 和大姐姐一起来计算! http://www.bilibili.tv/video/av362069/ http://www.youtube.com/watch?v=Q4gTV4r0zRs来自日本科学未来馆的趣味教育动画,介绍的是一个正方形由“起点(S)”到“终点(G)”会有多少种路线,以及关于大姐姐的催人泪下的故事 分析:http://oeis.org/A007764

  49. 为什么学习算法 原因之三:Just for fun!

  50. 算法分析基础

More Related