Tài liệu về Pseudocode tiếng anh
Cao Hoang TruCSE Faculty - HCMUT110 September 2008Chapter 1: Introduction• Pseudocode• Abstract data type• Algorithm efficiency Cao Hoang TruCSE Faculty - HCMUT210 September 2008Pseudocode• What is an algorithm? Cao Hoang TruCSE Faculty - HCMUT310 September 2008Pseudocode• What is an algorithm?–The logical steps to solve a problem. Cao Hoang TruCSE Faculty - HCMUT410 September 2008Pseudocode• What is a program?– Program = Data structures + Algorithms (Niklaus Wirth) Cao Hoang TruCSE Faculty - HCMUT510 September 2008Pseudocode• The most common tool to define algorithms.• English-like representation of the code required for an algorithm. Cao Hoang TruCSE Faculty - HCMUT610 September 2008Pseudocode• Pseudocode = English + Coderelaxed syntax being instructions using easy to read basic control structures(sequential, conditional, iterative) Cao Hoang TruCSE Faculty - HCMUT710 September 2008PseudocodeAlgorithm HeaderAlgorithm Body Cao Hoang TruCSE Faculty - HCMUT810 September 2008Pseudocode• Algorithm Header:– Name– Parameters and their types– Purpose• what the algorithm does– Precondition• precursor requirements for the parameters– Postcondition• taken action and status of the parameters– Return condition• returned value Cao Hoang TruCSE Faculty - HCMUT910 September 2008Pseudocode• Algorithm Body:– Statements– Statement numbers• decimal notation to express levels– Variables• important data– Algorithm analysis• comments to explain salient points– Statement constructs• sequence, selection, iteration Cao Hoang TruCSE Faculty - HCMUT1010 September 2008ExampleAlgorithm averagePre nothingPost numbers read and their average printed1 i = 02 loop (all data not read)1 i = i + 12 read number3 sum = sum + number3 average = sum / i4 print average5 returnEnd average [...]... nlog 2 n Cao Hoang Tru CSE Faculty - HCMUT 1 10 September 2008 Chapter 1: Introduction • Pseudocode • Abstract data type • Algorithm efficiency Cao Hoang Tru CSE Faculty - HCMUT 26 10 September 2008 Nested Loops Iterations = Outer loop iterations × Inner loop iterations Cao Hoang Tru CSE Faculty - HCMUT 9 10 September 2008 Pseudocode • Algorithm Body: – Statements – Statement numbers • decimal notation to... loop (i >= 1) 1 application code 1 application code 2 i = i × 2 2 i = i / 2 The number of times the body of the loop is replicated is log 2 n Cao Hoang Tru CSE Faculty - HCMUT 7 10 September 2008 Pseudocode Algorithm Header Algorithm Body Cao Hoang Tru CSE Faculty - HCMUT 37 10 September 2008 Big-O Analysis Examples Algorithm addMatrix (val matrix1 <matrix>, val matrix2 <matrix>, val... 2008 Big-O Notation • Set the coefficient of the term to one. • Keep the largest term and discard the others. log 2 n n nlog 2 n n 2 n 3 n k 2 n n! Cao Hoang Tru CSE Faculty - HCMUT 8 10 September 2008 Pseudocode • Algorithm Header: – Name – Parameters and their types – Purpose • what the algorithm does – Precondition • precursor requirements for the parameters – Postcondition • taken action and status . 2008Chapter 1: Introduction• Pseudocode Abstract data type• Algorithm efficiency Cao Hoang TruCSE Faculty - HCMUT210 September 200 8Pseudocode What is an algorithm? Cao. September 200 8Pseudocode What is an algorithm?–The logical steps to solve a problem. Cao Hoang TruCSE Faculty - HCMUT410 September 200 8Pseudocode What