SlideShare a Scribd company logo
1 of 44
Prepared By:
Mr. Richard R. Basilio
BSECE – Dip ICT
   By wikipedia definition:
      ▪ an algorithm is a sequence of finite instructions,
        often used for calculation and data processing.
      ▪ It is formally a type of effective method in which a
        list of well-defined instructions for completing a
        task will, when given an initial state, proceed
        through a well-defined series of successive states,
        eventually terminating in an end-state.
   First documented algorithm by Euclid (300 B.C.)
     to compute greatest common divisor (gcd).
     Example: gcd(3,21)=3
     Condition:
1. Let A and B be integers with A > B 0.
2. If B = 0, then the gcd is A and the algorithm ends.
3. Otherwise, find q and r such that
        A = qB + r where 0 r < B
   Note that we have 0 r < B < A and gcd(A,B) = gcd(B,r).
   Replace A by B, B by r. Go to step 2.
   Example No. 2:
     Find the greatest common divisor of A=40, B=15;
     using Euclidean algorithm;

         A = 2B + 10    A = 15 ; B = 10
         A = 1B + 5     A = 10 ; B = 5
         A = 2B + 0     A=5;B=0
         gcd is 5
   There are three properties of algorithm that
    must have to consider in solving a certain
    problem in programming:
       Finiteness
       Absence of Ambiguity
       Sequence Definition
       Input and Output Definition
       Effectiveness
       Scope of Definition
   Finiteness
     The execution of a programmed algorithm must
     be complete after a finite number of operations
     have been performed. Otherwise, we cannot
     claim that the execution produces a solution.
   Absence of Ambiguity
     The representation of every step of an algorithm
      should have a unique interpretation which also
      understand by the human.
     It is convenient to deal with algorithms presented
      in notational with sparse detail:
      ▪ Example:
       ▪ Pseudo code
       ▪ Flowcharts
   Sequence of Definition
     The sequence in which the steps of the algorithm
      are to carried out should be clearly specified.
     In algorithmic specifications, the instructions are
      performed from top to button, unless the
      instruction themselves otherwise specified.
   Input and Output Definition
     Inputs – are the data items that is presented in the
      algorithm.
     Outputs – are the data items presented to the
      outside world as the result of the execution of a
      program based on the algorithm.
     An algorithm ought to produce at least one
      output (otherwise, what use is it?...)
   Effectiveness
     it consists of basic instructions that are realizable.
      This means that the instructions can be
      performed by using the given inputs in a finite
      amount of time.
     The instructions of an algorithm may order the
      computer only to perform tasks that is capable of
      carrying out.
   Scope Definition
     An algorithm applies to the following:
      ▪ Specific problem or class of problem
      ▪ The range of inputs has to be predefined
      ▪ The range determines the generality of the algorithm.
   Algorithms can be expressed in many kinds of
    notation, including:
     Natural language
     Pseudo Code
     Flowcharts
     Programming Language
   “Pseudo” means imitation or false and “code”
    refers to the instructions written in a
    programming language.
   Pseudocode is another programming analysis
    tool that is used for planning a program.
   Pseudocode is also called Program Design
    Language (PDL).
   By wikipedia definition:
     Pseudocode is a compact and informal
      high-level description of a computer
      programming algorithm that uses the
      structural conventions of some
      programming language, but is intended for
      human reading rather than machine
      reading.
   Pseudocode is made up of the following logic
    structures that have been proved to be
    sufficient for writing any computer program:
     Sequence Logic
     Selection Logic
     Iteration Logic
   It is used to perform instructions in a
    sequence, that is one after another.
   Thus, for sequence logic, pseudocode
    instructions are written in an order in which
    they are to be performed.
   The logic flow of pseudocode is from top to
    bottom.
   It is used for making decisions and for
    selecting the proper path out of two or more
    alternative paths in program logic.
   It is also known as decision logic.
   Selection logic is depicted as either an
    IF...THEN or an IF...THEN...ELSE structure.
   It is used to produce loops when one or more
    instructions may be executed several times
    depending on some of the conditions.
   It uses structures called the DO_WHILE, FOR
    and the REPEAT_UNTIL.
1. Write only one statement per line.
   Each statement in your pseudocode should
    express just one action for the computer.
   If the task list is properly drawn, then in
    most cases each task will correspond to one
    line of pseudocode.
   Examples
2. Capitalized initial keyword.
   In the example above, READ and WRITE
    are in caps.
   There are just a few keywords we will use:
    ▪ READ, WRITE, IF, ELSE, ENDIF, WHILE,
      ENDWHILE, REPEAT, UNTIL
3. Indent to show hierarchy.
   We will use a particular indentation pattern in
    each of the design structures:
    ▪ SEQUENCE: keep statements that are “stacked” in
      sequence all starting in the same column.
    ▪ SELECTION: indent the statements that fall inside the
      selection structure, but not the keywords that form the
      selection
    ▪ LOOPING: indent the statements that fall inside the
      loop, but not the keywords that form the loop
   Examples:
4. End multi-line structures.
 ▫ All the initial keyword must always in line with the
   last or end of the structure.
5. Keep statement language independent.
 ▫ Resist the urge to write in whatever language you
   are most comfortable with. There may be special
   features available in the language you plan to
   eventually write the program in; if you are SURE it
   will be written in that language, then you can use
   the features. If not, then avoid using the special
   features.
   In summary:
     Write only one statement per line.
     Capitalized initial keyword.
     Indent to show hierarchy.
     End multi-line structures.
     Keep statement language independent.
•   These are follows:
    ▫ Number each instruction.
       This is to enforce the notion, “well-ordered collection of
        ... operations.”
    ▫ Each instruction should be unambiguous.
       It means the computing agent, in this case the reader,
        should be capable of carrying out the instructions. And
        also, each instruction should be effectively computable
        (do-able).
    ▫ Completeness.
       Nothing should be left out.
   Following are some of the advantages of
    using pseudocode:
     Converting a pseudocode to a programming
      language is much more easier than converting a
      flowchart.
     As compared to flowchart, it is easier to modify a
      pseudocode of a program logic when program
      modifications are necessary.
   It also suffers from some of the limitations.
    These limitations are as follows:
     In the cases of pseudocode, a graphic
      representation of program logic is not available.
     There are no standard rules to follow for using a
      pseudocode. Different programmers use their
      own style of writing pseudocode and hence,
      communication problem occurs due to lack of
      standardization.
   To symbolize the arithmetic operators we use
    these symbols:
     Note: There is a precedence or hierarchy implied
     in this symbols.
   When we have to make a choice between
    actions, we almost always base that choice
    on a test.
   There is a universally accepted set of symbols
    used to represent these phrases:
 It is more difficult to follow the
 logic of or write pseudocode as
 compared to flowcharting.
Prepare ½ crosswise yellow paper for
seatwork after the discussion.

More Related Content

What's hot

Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languagesVarun Garg
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmeticgavhays
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and AlgorithmDhaval Kaneria
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchartRabin BK
 
Looping statement in python
Looping statement in pythonLooping statement in python
Looping statement in pythonRaginiJain21
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGAbhishek Dwivedi
 
Flowcharts and algorithms
Flowcharts and algorithmsFlowcharts and algorithms
Flowcharts and algorithmsStudent
 
Variable and constants in Vb.NET
Variable and constants in Vb.NETVariable and constants in Vb.NET
Variable and constants in Vb.NETJaya Kumari
 
Evolution of Programming Languages
Evolution of Programming LanguagesEvolution of Programming Languages
Evolution of Programming LanguagesSayanee Basu
 
Computer data type and Terminologies
Computer data type and Terminologies Computer data type and Terminologies
Computer data type and Terminologies glyvive
 
Introduction to MS Word
Introduction to MS WordIntroduction to MS Word
Introduction to MS Wordshivamgupta949
 
Introduction to Algorithms & flow charts
Introduction to Algorithms & flow chartsIntroduction to Algorithms & flow charts
Introduction to Algorithms & flow chartsYash Gupta
 
Algorithms and flowcharts by Haseeb Khan
Algorithms and flowcharts by Haseeb KhanAlgorithms and flowcharts by Haseeb Khan
Algorithms and flowcharts by Haseeb KhanHaseeb Shalmani
 

What's hot (20)

Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmetic
 
Introduction to data structures and Algorithm
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
 
Compilers
CompilersCompilers
Compilers
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Pseudocode
PseudocodePseudocode
Pseudocode
 
Looping statement in python
Looping statement in pythonLooping statement in python
Looping statement in python
 
Introduction to problem solving in C
Introduction to problem solving in CIntroduction to problem solving in C
Introduction to problem solving in C
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
 
Flowcharts and algorithms
Flowcharts and algorithmsFlowcharts and algorithms
Flowcharts and algorithms
 
Pseudocode
PseudocodePseudocode
Pseudocode
 
Iteration
IterationIteration
Iteration
 
Variable and constants in Vb.NET
Variable and constants in Vb.NETVariable and constants in Vb.NET
Variable and constants in Vb.NET
 
Data Representation
Data RepresentationData Representation
Data Representation
 
Evolution of Programming Languages
Evolution of Programming LanguagesEvolution of Programming Languages
Evolution of Programming Languages
 
Computer data type and Terminologies
Computer data type and Terminologies Computer data type and Terminologies
Computer data type and Terminologies
 
Algorithm Introduction
Algorithm IntroductionAlgorithm Introduction
Algorithm Introduction
 
Introduction to MS Word
Introduction to MS WordIntroduction to MS Word
Introduction to MS Word
 
Introduction to Algorithms & flow charts
Introduction to Algorithms & flow chartsIntroduction to Algorithms & flow charts
Introduction to Algorithms & flow charts
 
Algorithms and flowcharts by Haseeb Khan
Algorithms and flowcharts by Haseeb KhanAlgorithms and flowcharts by Haseeb Khan
Algorithms and flowcharts by Haseeb Khan
 

Viewers also liked

Introduction to Pseudocode
Introduction to PseudocodeIntroduction to Pseudocode
Introduction to PseudocodeDamian T. Gordon
 
Flowchart pseudocode-examples
Flowchart pseudocode-examplesFlowchart pseudocode-examples
Flowchart pseudocode-examplesGautam Roy
 
Algorithm and flowchart2010
Algorithm and flowchart2010Algorithm and flowchart2010
Algorithm and flowchart2010Jordan Delacruz
 
Algorithmsandflowcharts1
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1luhkahreth
 

Viewers also liked (7)

Introduction to Pseudocode
Introduction to PseudocodeIntroduction to Pseudocode
Introduction to Pseudocode
 
Algorithms
AlgorithmsAlgorithms
Algorithms
 
Flowchart pseudocode-examples
Flowchart pseudocode-examplesFlowchart pseudocode-examples
Flowchart pseudocode-examples
 
Algorithm and flowchart2010
Algorithm and flowchart2010Algorithm and flowchart2010
Algorithm and flowchart2010
 
Algorithmsandflowcharts1
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1
 
Flowchart and algorithm
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithm
 
Writing algorithms
Writing algorithmsWriting algorithms
Writing algorithms
 

Similar to Algorithm and pseudo codes

4 coding from algorithms
4 coding from algorithms4 coding from algorithms
4 coding from algorithmshccit
 
Algorithms and flow charts
Algorithms and flow chartsAlgorithms and flow charts
Algorithms and flow chartsChinnu Edwin
 
Improving Code Quality Through Effective Review Process
Improving Code Quality Through Effective  Review ProcessImproving Code Quality Through Effective  Review Process
Improving Code Quality Through Effective Review ProcessDr. Syed Hassan Amin
 
PCCF UNIT 1.pptx
PCCF UNIT 1.pptxPCCF UNIT 1.pptx
PCCF UNIT 1.pptxDivyaKS12
 
02 Algorithms and flowcharts - computers.pptx
02 Algorithms and flowcharts - computers.pptx02 Algorithms and flowcharts - computers.pptx
02 Algorithms and flowcharts - computers.pptxarifaqazi2
 
Lec 2 -algorithms-flowchart-and-pseudocode1.pptx
Lec 2 -algorithms-flowchart-and-pseudocode1.pptxLec 2 -algorithms-flowchart-and-pseudocode1.pptx
Lec 2 -algorithms-flowchart-and-pseudocode1.pptxAbdelrahmanRagab36
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
Fundamentals of programming with C++
Fundamentals of programming with C++Fundamentals of programming with C++
Fundamentals of programming with C++Seble Nigussie
 
265 ge8151 problem solving and python programming - 2 marks with answers
265   ge8151 problem solving and python programming - 2 marks with answers265   ge8151 problem solving and python programming - 2 marks with answers
265 ge8151 problem solving and python programming - 2 marks with answersvithyanila
 
Algorithm-Introduction ,Characterestics & Control Structures.pdf
Algorithm-Introduction ,Characterestics & Control Structures.pdfAlgorithm-Introduction ,Characterestics & Control Structures.pdf
Algorithm-Introduction ,Characterestics & Control Structures.pdfMaryJacob24
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & LanguagesGaditek
 

Similar to Algorithm and pseudo codes (20)

3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
DAA Unit 1.pdf
DAA Unit 1.pdfDAA Unit 1.pdf
DAA Unit 1.pdf
 
4 coding from algorithms
4 coding from algorithms4 coding from algorithms
4 coding from algorithms
 
Introduction to programming c
Introduction to programming cIntroduction to programming c
Introduction to programming c
 
Algorithms and flow charts
Algorithms and flow chartsAlgorithms and flow charts
Algorithms and flow charts
 
Improving Code Quality Through Effective Review Process
Improving Code Quality Through Effective  Review ProcessImproving Code Quality Through Effective  Review Process
Improving Code Quality Through Effective Review Process
 
PCCF UNIT 1.pptx
PCCF UNIT 1.pptxPCCF UNIT 1.pptx
PCCF UNIT 1.pptx
 
Week10 final
Week10 finalWeek10 final
Week10 final
 
02 Algorithms and flowcharts - computers.pptx
02 Algorithms and flowcharts - computers.pptx02 Algorithms and flowcharts - computers.pptx
02 Algorithms and flowcharts - computers.pptx
 
Lec 2 -algorithms-flowchart-and-pseudocode1.pptx
Lec 2 -algorithms-flowchart-and-pseudocode1.pptxLec 2 -algorithms-flowchart-and-pseudocode1.pptx
Lec 2 -algorithms-flowchart-and-pseudocode1.pptx
 
Ic lecture8
Ic lecture8 Ic lecture8
Ic lecture8
 
Training 8051Report
Training 8051ReportTraining 8051Report
Training 8051Report
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Fundamentals of programming with C++
Fundamentals of programming with C++Fundamentals of programming with C++
Fundamentals of programming with C++
 
265 ge8151 problem solving and python programming - 2 marks with answers
265   ge8151 problem solving and python programming - 2 marks with answers265   ge8151 problem solving and python programming - 2 marks with answers
265 ge8151 problem solving and python programming - 2 marks with answers
 
Mcs lec2
Mcs lec2Mcs lec2
Mcs lec2
 
Introduction Of C++
Introduction Of C++Introduction Of C++
Introduction Of C++
 
Algorithm-Introduction ,Characterestics & Control Structures.pdf
Algorithm-Introduction ,Characterestics & Control Structures.pdfAlgorithm-Introduction ,Characterestics & Control Structures.pdf
Algorithm-Introduction ,Characterestics & Control Structures.pdf
 
c#.pptx
c#.pptxc#.pptx
c#.pptx
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & Languages
 

More from hermiraguilar

Introduction to programming concepts
Introduction to programming conceptsIntroduction to programming concepts
Introduction to programming conceptshermiraguilar
 
Programming process and flowchart
Programming process and flowchartProgramming process and flowchart
Programming process and flowcharthermiraguilar
 
Introduction to programming concepts
Introduction to programming conceptsIntroduction to programming concepts
Introduction to programming conceptshermiraguilar
 
Engineering drawing (geometric construction) lesson 4
Engineering drawing (geometric construction) lesson 4Engineering drawing (geometric construction) lesson 4
Engineering drawing (geometric construction) lesson 4hermiraguilar
 
Engineering drawing (introduction of engineering drawing) lesson 1
Engineering drawing (introduction of engineering drawing) lesson 1Engineering drawing (introduction of engineering drawing) lesson 1
Engineering drawing (introduction of engineering drawing) lesson 1hermiraguilar
 
Engineering drawing (engineering lettering) lesson 3
Engineering drawing (engineering lettering) lesson 3Engineering drawing (engineering lettering) lesson 3
Engineering drawing (engineering lettering) lesson 3hermiraguilar
 
Engineering drawing (drafting instruments) lesson 2
Engineering drawing (drafting instruments) lesson 2Engineering drawing (drafting instruments) lesson 2
Engineering drawing (drafting instruments) lesson 2hermiraguilar
 

More from hermiraguilar (7)

Introduction to programming concepts
Introduction to programming conceptsIntroduction to programming concepts
Introduction to programming concepts
 
Programming process and flowchart
Programming process and flowchartProgramming process and flowchart
Programming process and flowchart
 
Introduction to programming concepts
Introduction to programming conceptsIntroduction to programming concepts
Introduction to programming concepts
 
Engineering drawing (geometric construction) lesson 4
Engineering drawing (geometric construction) lesson 4Engineering drawing (geometric construction) lesson 4
Engineering drawing (geometric construction) lesson 4
 
Engineering drawing (introduction of engineering drawing) lesson 1
Engineering drawing (introduction of engineering drawing) lesson 1Engineering drawing (introduction of engineering drawing) lesson 1
Engineering drawing (introduction of engineering drawing) lesson 1
 
Engineering drawing (engineering lettering) lesson 3
Engineering drawing (engineering lettering) lesson 3Engineering drawing (engineering lettering) lesson 3
Engineering drawing (engineering lettering) lesson 3
 
Engineering drawing (drafting instruments) lesson 2
Engineering drawing (drafting instruments) lesson 2Engineering drawing (drafting instruments) lesson 2
Engineering drawing (drafting instruments) lesson 2
 

Recently uploaded

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 

Recently uploaded (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

Algorithm and pseudo codes

  • 1. Prepared By: Mr. Richard R. Basilio BSECE – Dip ICT
  • 2.
  • 3. By wikipedia definition: ▪ an algorithm is a sequence of finite instructions, often used for calculation and data processing. ▪ It is formally a type of effective method in which a list of well-defined instructions for completing a task will, when given an initial state, proceed through a well-defined series of successive states, eventually terminating in an end-state.
  • 4.
  • 5. First documented algorithm by Euclid (300 B.C.) to compute greatest common divisor (gcd).  Example: gcd(3,21)=3  Condition: 1. Let A and B be integers with A > B 0. 2. If B = 0, then the gcd is A and the algorithm ends. 3. Otherwise, find q and r such that A = qB + r where 0 r < B Note that we have 0 r < B < A and gcd(A,B) = gcd(B,r). Replace A by B, B by r. Go to step 2.
  • 6. Example No. 2:  Find the greatest common divisor of A=40, B=15; using Euclidean algorithm; A = 2B + 10 A = 15 ; B = 10 A = 1B + 5 A = 10 ; B = 5 A = 2B + 0 A=5;B=0 gcd is 5
  • 7. There are three properties of algorithm that must have to consider in solving a certain problem in programming:  Finiteness  Absence of Ambiguity  Sequence Definition  Input and Output Definition  Effectiveness  Scope of Definition
  • 8. Finiteness  The execution of a programmed algorithm must be complete after a finite number of operations have been performed. Otherwise, we cannot claim that the execution produces a solution.
  • 9. Absence of Ambiguity  The representation of every step of an algorithm should have a unique interpretation which also understand by the human.  It is convenient to deal with algorithms presented in notational with sparse detail: ▪ Example: ▪ Pseudo code ▪ Flowcharts
  • 10. Sequence of Definition  The sequence in which the steps of the algorithm are to carried out should be clearly specified.  In algorithmic specifications, the instructions are performed from top to button, unless the instruction themselves otherwise specified.
  • 11. Input and Output Definition  Inputs – are the data items that is presented in the algorithm.  Outputs – are the data items presented to the outside world as the result of the execution of a program based on the algorithm.  An algorithm ought to produce at least one output (otherwise, what use is it?...)
  • 12. Effectiveness  it consists of basic instructions that are realizable. This means that the instructions can be performed by using the given inputs in a finite amount of time.  The instructions of an algorithm may order the computer only to perform tasks that is capable of carrying out.
  • 13. Scope Definition  An algorithm applies to the following: ▪ Specific problem or class of problem ▪ The range of inputs has to be predefined ▪ The range determines the generality of the algorithm.
  • 14. Algorithms can be expressed in many kinds of notation, including:  Natural language  Pseudo Code  Flowcharts  Programming Language
  • 15.
  • 16. “Pseudo” means imitation or false and “code” refers to the instructions written in a programming language.  Pseudocode is another programming analysis tool that is used for planning a program.  Pseudocode is also called Program Design Language (PDL).
  • 17. By wikipedia definition:  Pseudocode is a compact and informal high-level description of a computer programming algorithm that uses the structural conventions of some programming language, but is intended for human reading rather than machine reading.
  • 18. Pseudocode is made up of the following logic structures that have been proved to be sufficient for writing any computer program:  Sequence Logic  Selection Logic  Iteration Logic
  • 19. It is used to perform instructions in a sequence, that is one after another.  Thus, for sequence logic, pseudocode instructions are written in an order in which they are to be performed.  The logic flow of pseudocode is from top to bottom.
  • 20.
  • 21. It is used for making decisions and for selecting the proper path out of two or more alternative paths in program logic.  It is also known as decision logic.  Selection logic is depicted as either an IF...THEN or an IF...THEN...ELSE structure.
  • 22.
  • 23.
  • 24. It is used to produce loops when one or more instructions may be executed several times depending on some of the conditions.  It uses structures called the DO_WHILE, FOR and the REPEAT_UNTIL.
  • 25.
  • 26.
  • 27.
  • 28. 1. Write only one statement per line.  Each statement in your pseudocode should express just one action for the computer.  If the task list is properly drawn, then in most cases each task will correspond to one line of pseudocode.
  • 29. Examples
  • 30. 2. Capitalized initial keyword.  In the example above, READ and WRITE are in caps.  There are just a few keywords we will use: ▪ READ, WRITE, IF, ELSE, ENDIF, WHILE, ENDWHILE, REPEAT, UNTIL
  • 31. 3. Indent to show hierarchy.  We will use a particular indentation pattern in each of the design structures: ▪ SEQUENCE: keep statements that are “stacked” in sequence all starting in the same column. ▪ SELECTION: indent the statements that fall inside the selection structure, but not the keywords that form the selection ▪ LOOPING: indent the statements that fall inside the loop, but not the keywords that form the loop
  • 32. Examples:
  • 33. 4. End multi-line structures. ▫ All the initial keyword must always in line with the last or end of the structure. 5. Keep statement language independent. ▫ Resist the urge to write in whatever language you are most comfortable with. There may be special features available in the language you plan to eventually write the program in; if you are SURE it will be written in that language, then you can use the features. If not, then avoid using the special features.
  • 34. In summary:  Write only one statement per line.  Capitalized initial keyword.  Indent to show hierarchy.  End multi-line structures.  Keep statement language independent.
  • 35. These are follows: ▫ Number each instruction.  This is to enforce the notion, “well-ordered collection of ... operations.” ▫ Each instruction should be unambiguous.  It means the computing agent, in this case the reader, should be capable of carrying out the instructions. And also, each instruction should be effectively computable (do-able). ▫ Completeness.  Nothing should be left out.
  • 36. Following are some of the advantages of using pseudocode:  Converting a pseudocode to a programming language is much more easier than converting a flowchart.  As compared to flowchart, it is easier to modify a pseudocode of a program logic when program modifications are necessary.
  • 37. It also suffers from some of the limitations. These limitations are as follows:  In the cases of pseudocode, a graphic representation of program logic is not available.  There are no standard rules to follow for using a pseudocode. Different programmers use their own style of writing pseudocode and hence, communication problem occurs due to lack of standardization.
  • 38. To symbolize the arithmetic operators we use these symbols:  Note: There is a precedence or hierarchy implied in this symbols.
  • 39. When we have to make a choice between actions, we almost always base that choice on a test.  There is a universally accepted set of symbols used to represent these phrases:
  • 40.
  • 41.
  • 42.
  • 43.  It is more difficult to follow the logic of or write pseudocode as compared to flowcharting.
  • 44. Prepare ½ crosswise yellow paper for seatwork after the discussion.