离散数学北京邮电大学PPT课件

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

.
8
Algorithm Characteristics
Some important general features of algorithms:
• Input. Information or data that comes in.
• Output. Information or data that goes out.
• You should know at least 1 real
language!
.
5
Algorithm Example (English)
ຫໍສະໝຸດ Baidu
• Task: Given a sequence {ai}=a1,…,an, aiN, say what its largest element is.
• One algorithm for doing this, in English:
Algorithms
Rosen 6th ed., §3.1
Abu al-Khowarizmi
(ca. 780-850)
.
1
Chapter 3: More Fundamentals
• §3.1: Algorithms
– Formal procedures
• §3.2: Growth of Functions • §3.3: Complexity of
• §3.6: Integers & Algorithms
– Alternate bases, algorithms for basic arithmetic
• §3.7: Applications of Number theory
– Public-Key Cryptography
• §3.8: Matrices
person whose job was to execute
algorithms!
.
7
Executing the Max algorithm
• Let {ai}=7,12,3,15,8. Find its maximum…
• Set v = a1 = 7. • Look at next element: a2 = 12. • Is a2>v? Yes, so change v to 12. • Look at next element: a2 = 3. • Is 3>12? No, leave v alone…. • Is 15>12? Yes, v=15…
– Older: Fortran, Cobol, Lisp, Basic
– Assembly languages, for low-level coding.
• In this class we will use an informal, Pascal-like “pseudo-code” language.
are no more elements in the sequence, & return v.
.
6
Executing an Algorithm
• When you start up a piece of software, we say the program or its algorithm are being run or executed by the computer.
algorithms
– Analysis using order-ofgrowth notation.
• §3.4: The Integers & Division
– Some basic number theory.
• §3.5: Primes and Greatest Common Divisors
• Given a description of an algorithm, you can also execute it by hand, by working through all of its steps with pencil & paper.
• Before ~1940, “computer” meant a
• A computer program is simply a description of an algorithm, in a language precise enough for a computer to understand, requiring only operations that the computer already knows how to do.
• Definiteness. Algorithm is precisely defined.
• Correctness. Outputs correctly relate to inputs.
– Set the value of a temporary variable v (largest element seen so far) to a1’s value.
– Look at the next element ai in the sequence.
– If ai>v, then re-assign v to the number ai. – Repeat then previous 2 steps until there
– Some basic linear algebra.
.
2
§3.1: Algorithms
• The foundation of computer programming.
• Most generally, an algorithm just means a definite procedure for performing some sort of task.
• We say that a program implements (or “is an
implementation of”) its. algorithm.
3
Programming Languages
• Some common programming languages:
– Newer: Java, C, C++, C#, Visual Basic, JavaScript, Perl, Tcl, Pascal, many others…
相关文档
最新文档