Algorithm and pseudo codes

Prepared By:
Mr. Richard R. Basilio
BSECE – Dip ICT
Algorithm and pseudo codes
   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.
Algorithm and pseudo codes
   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
Algorithm and pseudo codes
   “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.
Algorithm and pseudo codes
   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.
Algorithm and pseudo codes
Algorithm and pseudo codes
   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.
Algorithm and pseudo codes
Algorithm and pseudo codes
Algorithm and pseudo codes
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:
Algorithm and pseudo codes
Algorithm and pseudo codes
Algorithm and pseudo codes
 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.
1 de 44

Recomendados

Algorithm por
AlgorithmAlgorithm
AlgorithmIHTISHAM UL HAQ
7.7K visualizações16 slides
Algorithms and Flowcharts por
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and FlowchartsDeva Singh
309.9K visualizações31 slides
Programming Fundamentals por
Programming FundamentalsProgramming Fundamentals
Programming FundamentalsTrivuz ত্রিভুজ
24.7K visualizações42 slides
Unit 1-problem solving with algorithm por
Unit 1-problem solving with algorithmUnit 1-problem solving with algorithm
Unit 1-problem solving with algorithmrajkumar1631010038
6.9K visualizações26 slides
Lect 1. introduction to programming languages por
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languagesVarun Garg
235.2K visualizações33 slides
Algorithm and flowchart por
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchartElizabeth de Leon Aler
87.3K visualizações9 slides

Mais conteúdo relacionado

Mais procurados

Analysis of algorithms por
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithmsGanesh Solanke
15.9K visualizações62 slides
Introduction to Pseudocode por
Introduction to PseudocodeIntroduction to Pseudocode
Introduction to PseudocodeDamian T. Gordon
339.4K visualizações64 slides
Techniques & applications of Compiler por
Techniques & applications of CompilerTechniques & applications of Compiler
Techniques & applications of CompilerPreethi AKNR
13.3K visualizações6 slides
Basics of c++ Programming Language por
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming LanguageAhmad Idrees
47.8K visualizações78 slides
Algorithm and flowchart por
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchartRabin BK
10.7K visualizações17 slides
Introduction to computer programming por
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programmingNSU-Biliran Campus
16.3K visualizações18 slides

Mais procurados(20)

Analysis of algorithms por Ganesh Solanke
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
Ganesh Solanke15.9K visualizações
Introduction to Pseudocode por Damian T. Gordon
Introduction to PseudocodeIntroduction to Pseudocode
Introduction to Pseudocode
Damian T. Gordon339.4K visualizações
Techniques & applications of Compiler por Preethi AKNR
Techniques & applications of CompilerTechniques & applications of Compiler
Techniques & applications of Compiler
Preethi AKNR13.3K visualizações
Basics of c++ Programming Language por Ahmad Idrees
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
Ahmad Idrees47.8K visualizações
Algorithm and flowchart por Rabin BK
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
Rabin BK10.7K visualizações
Introduction to computer programming por NSU-Biliran Campus
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
NSU-Biliran Campus16.3K visualizações
Our presentation on algorithm design por Nahid Hasan
Our presentation on algorithm designOur presentation on algorithm design
Our presentation on algorithm design
Nahid Hasan22K visualizações
High level and Low level Language por adnan usmani
High level and Low level Language High level and Low level Language
High level and Low level Language
adnan usmani4.4K visualizações
Algorithms and flow charts por Chinnu Edwin
Algorithms and flow chartsAlgorithms and flow charts
Algorithms and flow charts
Chinnu Edwin178 visualizações
Pseudocode por grahamwell
PseudocodePseudocode
Pseudocode
grahamwell3.3K visualizações
Programming Fundamental Presentation por fazli khaliq
Programming Fundamental PresentationProgramming Fundamental Presentation
Programming Fundamental Presentation
fazli khaliq2.1K visualizações
Problem solving using Computer por David Livingston J
Problem solving using ComputerProblem solving using Computer
Problem solving using Computer
David Livingston J10K visualizações
SPL 2 | Algorithms, Pseudo-code, and Flowchart por Mohammad Imam Hossain
SPL 2 | Algorithms, Pseudo-code, and FlowchartSPL 2 | Algorithms, Pseudo-code, and Flowchart
SPL 2 | Algorithms, Pseudo-code, and Flowchart
Mohammad Imam Hossain428 visualizações
Introduction to c programming por ABHISHEK fulwadhwa
Introduction to c programmingIntroduction to c programming
Introduction to c programming
ABHISHEK fulwadhwa4.6K visualizações
Introduction to data structures and Algorithm por Dhaval Kaneria
Introduction to data structures and AlgorithmIntroduction to data structures and Algorithm
Introduction to data structures and Algorithm
Dhaval Kaneria45.6K visualizações
What is an algorithm? por Angela DeHart
What is an algorithm?What is an algorithm?
What is an algorithm?
Angela DeHart18.5K visualizações
Data Structures and Algorithm - Module 1.pptx por EllenGrace9
Data Structures and Algorithm - Module 1.pptxData Structures and Algorithm - Module 1.pptx
Data Structures and Algorithm - Module 1.pptx
EllenGrace91.4K visualizações
Algorithm Introduction por Ashim Lamichhane
Algorithm IntroductionAlgorithm Introduction
Algorithm Introduction
Ashim Lamichhane10.9K visualizações
Algorithms Lecture 2: Analysis of Algorithms I por Benha University
Algorithms Lecture 2: Analysis of Algorithms IAlgorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms I
Benha University6.1K visualizações

Destaque

Algorithms por
AlgorithmsAlgorithms
AlgorithmsLiam Dunphy
48.9K visualizações32 slides
Flowchart pseudocode-examples por
Flowchart pseudocode-examplesFlowchart pseudocode-examples
Flowchart pseudocode-examplesGautam Roy
62.6K visualizações4 slides
Algorithm and flowchart2010 por
Algorithm and flowchart2010Algorithm and flowchart2010
Algorithm and flowchart2010Jordan Delacruz
22.5K visualizações12 slides
Algorithmsandflowcharts1 por
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1luhkahreth
49.7K visualizações32 slides
Flowchart and algorithm por
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithmSayali Shivarkar
69.8K visualizações10 slides
Writing algorithms por
Writing algorithmsWriting algorithms
Writing algorithms Krishna Chaytaniah
111.3K visualizações17 slides

Destaque(6)

Algorithms por Liam Dunphy
AlgorithmsAlgorithms
Algorithms
Liam Dunphy48.9K visualizações
Flowchart pseudocode-examples por Gautam Roy
Flowchart pseudocode-examplesFlowchart pseudocode-examples
Flowchart pseudocode-examples
Gautam Roy62.6K visualizações
Algorithm and flowchart2010 por Jordan Delacruz
Algorithm and flowchart2010Algorithm and flowchart2010
Algorithm and flowchart2010
Jordan Delacruz22.5K visualizações
Algorithmsandflowcharts1 por luhkahreth
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1
luhkahreth49.7K visualizações
Flowchart and algorithm por Sayali Shivarkar
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithm
Sayali Shivarkar69.8K visualizações
Writing algorithms por Krishna Chaytaniah
Writing algorithmsWriting algorithms
Writing algorithms
Krishna Chaytaniah111.3K visualizações

Similar a Algorithm and pseudo codes

3 algorithm-and-flowchart por
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchartRohit Shrivastava
15.1K visualizações37 slides
DAA Unit 1.pdf por
DAA Unit 1.pdfDAA Unit 1.pdf
DAA Unit 1.pdfNirmalavenkatachalam
71 visualizações38 slides
4 coding from algorithms por
4 coding from algorithms4 coding from algorithms
4 coding from algorithmshccit
12K visualizações41 slides
Introduction to programming c por
Introduction to programming cIntroduction to programming c
Introduction to programming cMd. Rakibuzzaman Khan Pathan
41 visualizações25 slides
Improving Code Quality Through Effective Review Process por
Improving Code Quality Through Effective  Review ProcessImproving Code Quality Through Effective  Review Process
Improving Code Quality Through Effective Review ProcessDr. Syed Hassan Amin
721 visualizações32 slides
PCCF UNIT 1.pptx por
PCCF UNIT 1.pptxPCCF UNIT 1.pptx
PCCF UNIT 1.pptxDivyaKS12
25 visualizações61 slides

Similar a Algorithm and pseudo codes(20)

3 algorithm-and-flowchart por Rohit Shrivastava
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
Rohit Shrivastava15.1K visualizações
4 coding from algorithms por hccit
4 coding from algorithms4 coding from algorithms
4 coding from algorithms
hccit12K visualizações
Improving Code Quality Through Effective Review Process por Dr. Syed Hassan Amin
Improving Code Quality Through Effective  Review ProcessImproving Code Quality Through Effective  Review Process
Improving Code Quality Through Effective Review Process
Dr. Syed Hassan Amin721 visualizações
PCCF UNIT 1.pptx por DivyaKS12
PCCF UNIT 1.pptxPCCF UNIT 1.pptx
PCCF UNIT 1.pptx
DivyaKS1225 visualizações
Week10 final por Irfan Ali Memon
Week10 finalWeek10 final
Week10 final
Irfan Ali Memon517 visualizações
Lec 2 -algorithms-flowchart-and-pseudocode1.pptx por AbdelrahmanRagab36
Lec 2 -algorithms-flowchart-and-pseudocode1.pptxLec 2 -algorithms-flowchart-and-pseudocode1.pptx
Lec 2 -algorithms-flowchart-and-pseudocode1.pptx
AbdelrahmanRagab3623 visualizações
Training 8051Report por Kuldeep Kaushik
Training 8051ReportTraining 8051Report
Training 8051Report
Kuldeep Kaushik218 visualizações
POLITEKNIK MALAYSIA por Aiman Hud
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud47 visualizações
Fundamentals of programming with C++ por Seble Nigussie
Fundamentals of programming with C++Fundamentals of programming with C++
Fundamentals of programming with C++
Seble Nigussie245 visualizações
265 ge8151 problem solving and python programming - 2 marks with answers por vithyanila
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
vithyanila458 visualizações
Mcs lec2 por Faiza Gull
Mcs lec2Mcs lec2
Mcs lec2
Faiza Gull268 visualizações
Introduction Of C++ por Sangharsh agarwal
Introduction Of C++Introduction Of C++
Introduction Of C++
Sangharsh agarwal6K visualizações
Algorithm-Introduction ,Characterestics & Control Structures.pdf por MaryJacob24
Algorithm-Introduction ,Characterestics & Control Structures.pdfAlgorithm-Introduction ,Characterestics & Control Structures.pdf
Algorithm-Introduction ,Characterestics & Control Structures.pdf
MaryJacob2461 visualizações
Programming Paradigm & Languages por Gaditek
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & Languages
Gaditek397 visualizações
Programming Paradigm & Languages por Gaditek
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & Languages
Gaditek3.4K visualizações
C Programming Unit-1 por Vikram Nandini
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
Vikram Nandini487 visualizações

Mais de hermiraguilar

Introduction to programming concepts por
Introduction to programming conceptsIntroduction to programming concepts
Introduction to programming conceptshermiraguilar
2.4K visualizações55 slides
Programming process and flowchart por
Programming process and flowchartProgramming process and flowchart
Programming process and flowcharthermiraguilar
9.6K visualizações34 slides
Introduction to programming concepts por
Introduction to programming conceptsIntroduction to programming concepts
Introduction to programming conceptshermiraguilar
2.6K visualizações55 slides
Engineering drawing (geometric construction) lesson 4 por
Engineering drawing (geometric construction) lesson 4Engineering drawing (geometric construction) lesson 4
Engineering drawing (geometric construction) lesson 4hermiraguilar
77.6K visualizações60 slides
Engineering drawing (introduction of engineering drawing) lesson 1 por
Engineering drawing (introduction of engineering drawing) lesson 1Engineering drawing (introduction of engineering drawing) lesson 1
Engineering drawing (introduction of engineering drawing) lesson 1hermiraguilar
25K visualizações39 slides
Engineering drawing (engineering lettering) lesson 3 por
Engineering drawing (engineering lettering) lesson 3Engineering drawing (engineering lettering) lesson 3
Engineering drawing (engineering lettering) lesson 3hermiraguilar
137.1K visualizações28 slides

Mais de hermiraguilar(7)

Introduction to programming concepts por hermiraguilar
Introduction to programming conceptsIntroduction to programming concepts
Introduction to programming concepts
hermiraguilar2.4K visualizações
Programming process and flowchart por hermiraguilar
Programming process and flowchartProgramming process and flowchart
Programming process and flowchart
hermiraguilar9.6K visualizações
Introduction to programming concepts por hermiraguilar
Introduction to programming conceptsIntroduction to programming concepts
Introduction to programming concepts
hermiraguilar2.6K visualizações
Engineering drawing (geometric construction) lesson 4 por hermiraguilar
Engineering drawing (geometric construction) lesson 4Engineering drawing (geometric construction) lesson 4
Engineering drawing (geometric construction) lesson 4
hermiraguilar77.6K visualizações
Engineering drawing (introduction of engineering drawing) lesson 1 por hermiraguilar
Engineering drawing (introduction of engineering drawing) lesson 1Engineering drawing (introduction of engineering drawing) lesson 1
Engineering drawing (introduction of engineering drawing) lesson 1
hermiraguilar25K visualizações
Engineering drawing (engineering lettering) lesson 3 por hermiraguilar
Engineering drawing (engineering lettering) lesson 3Engineering drawing (engineering lettering) lesson 3
Engineering drawing (engineering lettering) lesson 3
hermiraguilar137.1K visualizações
Engineering drawing (drafting instruments) lesson 2 por hermiraguilar
Engineering drawing (drafting instruments) lesson 2Engineering drawing (drafting instruments) lesson 2
Engineering drawing (drafting instruments) lesson 2
hermiraguilar35.8K visualizações

Último

Future of AR - Facebook Presentation por
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook Presentationssuserb54b561
15 visualizações27 slides
Ransomware is Knocking your Door_Final.pdf por
Ransomware is Knocking your Door_Final.pdfRansomware is Knocking your Door_Final.pdf
Ransomware is Knocking your Door_Final.pdfSecurity Bootcamp
59 visualizações46 slides
Data Integrity for Banking and Financial Services por
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial ServicesPrecisely
25 visualizações26 slides
NET Conf 2023 Recap por
NET Conf 2023 RecapNET Conf 2023 Recap
NET Conf 2023 RecapLee Richardson
10 visualizações71 slides
The Research Portal of Catalonia: Growing more (information) & more (services) por
The Research Portal of Catalonia: Growing more (information) & more (services)The Research Portal of Catalonia: Growing more (information) & more (services)
The Research Portal of Catalonia: Growing more (information) & more (services)CSUC - Consorci de Serveis Universitaris de Catalunya
80 visualizações25 slides
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive por
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveNetwork Automation Forum
34 visualizações35 slides

Último(20)

Future of AR - Facebook Presentation por ssuserb54b561
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook Presentation
ssuserb54b56115 visualizações
Ransomware is Knocking your Door_Final.pdf por Security Bootcamp
Ransomware is Knocking your Door_Final.pdfRansomware is Knocking your Door_Final.pdf
Ransomware is Knocking your Door_Final.pdf
Security Bootcamp59 visualizações
Data Integrity for Banking and Financial Services por Precisely
Data Integrity for Banking and Financial ServicesData Integrity for Banking and Financial Services
Data Integrity for Banking and Financial Services
Precisely25 visualizações
NET Conf 2023 Recap por Lee Richardson
NET Conf 2023 RecapNET Conf 2023 Recap
NET Conf 2023 Recap
Lee Richardson10 visualizações
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive por Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Network Automation Forum34 visualizações
Voice Logger - Telephony Integration Solution at Aegis por Nirmal Sharma
Voice Logger - Telephony Integration Solution at AegisVoice Logger - Telephony Integration Solution at Aegis
Voice Logger - Telephony Integration Solution at Aegis
Nirmal Sharma39 visualizações
Unit 1_Lecture 2_Physical Design of IoT.pdf por StephenTec
Unit 1_Lecture 2_Physical Design of IoT.pdfUnit 1_Lecture 2_Physical Design of IoT.pdf
Unit 1_Lecture 2_Physical Design of IoT.pdf
StephenTec12 visualizações
Five Things You SHOULD Know About Postman por Postman
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About Postman
Postman36 visualizações
Info Session November 2023.pdf por AleksandraKoprivica4
Info Session November 2023.pdfInfo Session November 2023.pdf
Info Session November 2023.pdf
AleksandraKoprivica413 visualizações
Evolving the Network Automation Journey from Python to Platforms por Network Automation Forum
Evolving the Network Automation Journey from Python to PlatformsEvolving the Network Automation Journey from Python to Platforms
Evolving the Network Automation Journey from Python to Platforms
Network Automation Forum13 visualizações
Special_edition_innovator_2023.pdf por WillDavies22
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdf
WillDavies2218 visualizações
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... por James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson92 visualizações
Business Analyst Series 2023 - Week 3 Session 5 por DianaGray10
Business Analyst Series 2023 -  Week 3 Session 5Business Analyst Series 2023 -  Week 3 Session 5
Business Analyst Series 2023 - Week 3 Session 5
DianaGray10300 visualizações
HTTP headers that make your website go faster - devs.gent November 2023 por Thijs Feryn
HTTP headers that make your website go faster - devs.gent November 2023HTTP headers that make your website go faster - devs.gent November 2023
HTTP headers that make your website go faster - devs.gent November 2023
Thijs Feryn22 visualizações
Democratising digital commerce in India-Report por Kapil Khandelwal (KK)
Democratising digital commerce in India-ReportDemocratising digital commerce in India-Report
Democratising digital commerce in India-Report
Kapil Khandelwal (KK)18 visualizações
Microsoft Power Platform.pptx por Uni Systems S.M.S.A.
Microsoft Power Platform.pptxMicrosoft Power Platform.pptx
Microsoft Power Platform.pptx
Uni Systems S.M.S.A.53 visualizações
Piloting & Scaling Successfully With Microsoft Viva por Richard Harbridge
Piloting & Scaling Successfully With Microsoft VivaPiloting & Scaling Successfully With Microsoft Viva
Piloting & Scaling Successfully With Microsoft Viva
Richard Harbridge12 visualizações
PRODUCT PRESENTATION.pptx por angelicacueva6
PRODUCT PRESENTATION.pptxPRODUCT PRESENTATION.pptx
PRODUCT PRESENTATION.pptx
angelicacueva615 visualizações

Algorithm and pseudo codes

  • 1. Prepared By: Mr. Richard R. Basilio BSECE – Dip ICT
  • 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.
  • 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
  • 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.
  • 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.
  • 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.
  • 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:
  • 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.