SlideShare ist ein Scribd-Unternehmen logo
1 von 12
Algorithms


      for
Program Design


                 1
Process Modelling
Process modelling is performed during the design
stage of developing a new system.
Data Flow Diagrams - show WHAT the new system
must be able to do.
Process Specification - provides details of HOW the
required functionality is achieved.
Various techniques used to clarify procedures
   Structure Diagrams
   Flow Charts
   Pseudocode / Structured English

Provides the logical design for a computer algorithm
                                                       2
Start
           Start
                                               Flow Charts
     Subtotal = 00
      Subtotal =                  •   Not to be confused with Data Flow Diagrams (DFDs)
     VAT = 1.175
     VAT = 1.175                      Shows steps required to achieve the
                                      correct outcome
    Input: ItemPrice
     Input: ItemPrice                 Flow charts provide a graphical
                                      representation of an algorithm
 Subtotal = Subtotal +
  Subtotal = Subtotal +                •   Can become complex and hard to follow
      ItemPrice
       ItemPrice                       •   Best used to give overview of functionality.
                                      Pseudocode provides a non-technical
                             no
    End of Item list?
     End of Item list?                description of an algorithm
                                       •   More detailed and closely related to
             yes                           programming code
Total = Subtotal **VAT
 Total = Subtotal VAT                 Structure diagrams are useful to show a
                                      hierarchical overview of program modules
        Output:
         Output:                       •   Helps to identify how the main project
“Total Price = £” (Total)
 “Total Price = £” (Total)                 components will be created
                                       •   Input - Processing - Output
          Stop
           Stop
                                                                                          3
Pseudocode
Pseudocode is a technique used during the design
stage of developing a program.
Used to translate the users requirements into a into a
complete sequence of unambiguous, logical steps.
It is written in Structured English to describe the
system operations accurately and precisely,
including all the steps need to code the program.
Can be understood by any programmer & coded into
any language.

                                                         4
How to….Create an Algorithm
 Start with a statement of the user’s needs
 Then write a program specification
 Then write out in sentences what the
 program needs to do at each step
 All of the time, consider how a computer runs
 an event driven program
   INPUT – PROCESS – OUTPUT



                                                 5
How to ... Pseudocode
Starting with general sentences (Structured English)
Remove as many of the extra words as you can - just
leave the bare minimum
If values are being entered - input:
   use the term “read in” or “get”…..
For any processing or calculations
   use the logical operators + - * / < > = “True”, “False”
If results are being displayed - output:
   use the term “print”
The final pseudocode should be language independent,
but must avoid any ambiguity.
                                                             6
Example:
  Description of the stages of a program for
  adding two numbers and displaying the result:

The user types in Number1
The user types in Number2
The program adds Number1 and Number2
The program displays the Total on the screen

  This isn’t written in pseudocode quite yet……


                                                  7
Example:

Read in Number1
Read in Number2
Total = Number1 + Number2
Print (Total)

 Now this is like program code
 Because of this it is called pseudocode
 Structured English is what it is written in


                                               8
Example: Verify Product




                          9
Example: Verify Product

For each Ordered Product
        Get Product(CatNo), Ordered(CatNo)
        If Product(CatNo) = Ordered (CatNo) Then
                Get Product (Level), Ordered (Quantity),
                If Product (Level) >= Ordered (Quantity) Then
                Order accepted = True
                Else
                Order accepted = False
                End If
        Else
                Print Invalid Product No
        End If
Next Product
Print confirmed order
                                                                10
Example: HND course




                      11
Example: Credit Card Authorisation
 START Bank connection
 GET Total due, Card type, Card number, Expiry date
 GET Stolen cards list
 IF Stolen = True THEN
            Print “Retain card and destroy”
 ELSE
            LOOP WHILE Counter < 3 AND PIN = False
                       Increment Counter
                       GET PIN
                       IF PIN = True THEN
                                  GET Limit, Balance
                                  IF Total Due < Limit - Balance THEN
                                             GET Ref (Transaction)
                                             Balance = Balance + Total Due
                                             PRINT “Transaction authorised” & Ref
                                  ELSE Authorised = False
                                             PRINT “Insufficient funds available”
                                  END IF
                                  EXIT Bank connection
                       END IF
            END LOOP
             PRINT “Incorrect PIN - Retain card and refer to bank”
 END IF
 EXIT Bank connection
                                                                                    12

Weitere ähnliche Inhalte

Was ist angesagt?

Pseudocode algorithim flowchart
Pseudocode algorithim flowchartPseudocode algorithim flowchart
Pseudocode algorithim flowchartfika sweety
 
Introduction to Algorithms & flow charts
Introduction to Algorithms & flow chartsIntroduction to Algorithms & flow charts
Introduction to Algorithms & flow chartsYash Gupta
 
Csc 130 class 2 problem analysis and flow charts(2)
Csc 130 class 2   problem analysis and flow charts(2)Csc 130 class 2   problem analysis and flow charts(2)
Csc 130 class 2 problem analysis and flow charts(2)Puneet narula
 
Introduction to flowchart
Introduction to flowchartIntroduction to flowchart
Introduction to flowchartJordan Delacruz
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchartSachin Goyani
 
Flowchart and algorithem
Flowchart and algorithemFlowchart and algorithem
Flowchart and algorithemehsanullah786
 
Algorithms and flowcharts
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowchartsSamuel Igbanogu
 
Algorithmsandflowcharts1
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1luhkahreth
 
2.3 Apply the different types of algorithm to solve problem
2.3 Apply the different types of algorithm to solve problem2.3 Apply the different types of algorithm to solve problem
2.3 Apply the different types of algorithm to solve problemFrankie Jones
 
pseudocode and Flowchart
pseudocode and Flowchartpseudocode and Flowchart
pseudocode and FlowchartALI RAZA
 
Computer programming:Know How to Flowchart
Computer  programming:Know How to FlowchartComputer  programming:Know How to Flowchart
Computer programming:Know How to FlowchartAngelo Tomboc
 
Chapter 6 algorithms and flow charts
Chapter 6  algorithms and flow chartsChapter 6  algorithms and flow charts
Chapter 6 algorithms and flow chartsPraveen M Jigajinni
 
flowchart & algorithms
flowchart & algorithmsflowchart & algorithms
flowchart & algorithmsStudent
 
Flowchart and algorithm
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithmDHANIK VIKRANT
 

Was ist angesagt? (20)

Pseudocode algorithim flowchart
Pseudocode algorithim flowchartPseudocode algorithim flowchart
Pseudocode algorithim flowchart
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Introduction to Algorithms & flow charts
Introduction to Algorithms & flow chartsIntroduction to Algorithms & flow charts
Introduction to Algorithms & flow charts
 
Pseudocode
PseudocodePseudocode
Pseudocode
 
Problem solving and design
Problem solving and designProblem solving and design
Problem solving and design
 
Pseudocode By ZAK
Pseudocode By ZAKPseudocode By ZAK
Pseudocode By ZAK
 
Csc 130 class 2 problem analysis and flow charts(2)
Csc 130 class 2   problem analysis and flow charts(2)Csc 130 class 2   problem analysis and flow charts(2)
Csc 130 class 2 problem analysis and flow charts(2)
 
Introduction to flowchart
Introduction to flowchartIntroduction to flowchart
Introduction to flowchart
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Flowchart and algorithem
Flowchart and algorithemFlowchart and algorithem
Flowchart and algorithem
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
Algorithms and flowcharts
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowcharts
 
Algorithmsandflowcharts1
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1
 
2.3 Apply the different types of algorithm to solve problem
2.3 Apply the different types of algorithm to solve problem2.3 Apply the different types of algorithm to solve problem
2.3 Apply the different types of algorithm to solve problem
 
Flowchart
FlowchartFlowchart
Flowchart
 
pseudocode and Flowchart
pseudocode and Flowchartpseudocode and Flowchart
pseudocode and Flowchart
 
Computer programming:Know How to Flowchart
Computer  programming:Know How to FlowchartComputer  programming:Know How to Flowchart
Computer programming:Know How to Flowchart
 
Chapter 6 algorithms and flow charts
Chapter 6  algorithms and flow chartsChapter 6  algorithms and flow charts
Chapter 6 algorithms and flow charts
 
flowchart & algorithms
flowchart & algorithmsflowchart & algorithms
flowchart & algorithms
 
Flowchart and algorithm
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithm
 

Andere mochten auch (20)

Chap09
Chap09Chap09
Chap09
 
Erakartzeko marketing aurkezpena
Erakartzeko marketing aurkezpenaErakartzeko marketing aurkezpena
Erakartzeko marketing aurkezpena
 
Chap15
Chap15Chap15
Chap15
 
Chap14
Chap14Chap14
Chap14
 
Risk taking and emotions
Risk taking and emotionsRisk taking and emotions
Risk taking and emotions
 
Chap04
Chap04Chap04
Chap04
 
Chap05
Chap05Chap05
Chap05
 
Chap06
Chap06Chap06
Chap06
 
Chap17
Chap17Chap17
Chap17
 
Asi Chap005
Asi Chap005Asi Chap005
Asi Chap005
 
Decisions
DecisionsDecisions
Decisions
 
Simple debugging
Simple debuggingSimple debugging
Simple debugging
 
Data types vbnet
Data types vbnetData types vbnet
Data types vbnet
 
Design for edp
Design for edpDesign for edp
Design for edp
 
Software development lifecycle
Software development lifecycleSoftware development lifecycle
Software development lifecycle
 
Ch 3 event driven programming
Ch 3 event driven programmingCh 3 event driven programming
Ch 3 event driven programming
 
Data structures vb
Data structures vbData structures vb
Data structures vb
 
Ndu06 typesof language
Ndu06 typesof languageNdu06 typesof language
Ndu06 typesof language
 
Decisions
DecisionsDecisions
Decisions
 
Design documentation
Design documentationDesign documentation
Design documentation
 

Ähnlich wie Algorithms

learn computer science.ppt
learn computer science.pptlearn computer science.ppt
learn computer science.pptfaithola1
 
Introduction to C++
Introduction to C++ Introduction to C++
Introduction to C++ Bharat Kalia
 
Programming For As Comp
Programming For As CompProgramming For As Comp
Programming For As CompDavid Halliday
 
Programming For As Comp
Programming For As CompProgramming For As Comp
Programming For As CompDavid Halliday
 
Introduction to programming by MUFIX Commnity
Introduction to programming by MUFIX CommnityIntroduction to programming by MUFIX Commnity
Introduction to programming by MUFIX Commnitymazenet
 
Unit 1-problem solving with algorithm
Unit 1-problem solving with algorithmUnit 1-problem solving with algorithm
Unit 1-problem solving with algorithmrajkumar1631010038
 
BP206 - Let's Give Your LotusScript a Tune-Up
BP206 - Let's Give Your LotusScript a Tune-Up BP206 - Let's Give Your LotusScript a Tune-Up
BP206 - Let's Give Your LotusScript a Tune-Up Craig Schumann
 
Introduction To Programming
Introduction To ProgrammingIntroduction To Programming
Introduction To Programmingcwarren
 
Functional pogramming hl overview
Functional pogramming hl overviewFunctional pogramming hl overview
Functional pogramming hl overviewElad Avneri
 
The Power of Composition
The Power of CompositionThe Power of Composition
The Power of CompositionScott Wlaschin
 
4. programing 101
4. programing 1014. programing 101
4. programing 101IEEE MIU SB
 
Help with Pyhon Programming Homework
Help with Pyhon Programming HomeworkHelp with Pyhon Programming Homework
Help with Pyhon Programming HomeworkHelpmeinhomework
 
Reinventing the Transaction Script (NDC London 2020)
Reinventing the Transaction Script (NDC London 2020)Reinventing the Transaction Script (NDC London 2020)
Reinventing the Transaction Script (NDC London 2020)Scott Wlaschin
 
resolvendo problemas de comunicação em equipes distribuídas com bdd
resolvendo problemas de comunicação em equipes distribuídas com bddresolvendo problemas de comunicação em equipes distribuídas com bdd
resolvendo problemas de comunicação em equipes distribuídas com bddRodrigo Urubatan
 

Ähnlich wie Algorithms (20)

learn computer science.ppt
learn computer science.pptlearn computer science.ppt
learn computer science.ppt
 
Introduction to C++
Introduction to C++ Introduction to C++
Introduction to C++
 
Programming For As Comp
Programming For As CompProgramming For As Comp
Programming For As Comp
 
Programming For As Comp
Programming For As CompProgramming For As Comp
Programming For As Comp
 
Class 8 Lecture Notes
Class 8 Lecture NotesClass 8 Lecture Notes
Class 8 Lecture Notes
 
Introduction To Programming (2009 2010)
Introduction To Programming (2009 2010)Introduction To Programming (2009 2010)
Introduction To Programming (2009 2010)
 
Introduction to programming by MUFIX Commnity
Introduction to programming by MUFIX CommnityIntroduction to programming by MUFIX Commnity
Introduction to programming by MUFIX Commnity
 
Unit 1-problem solving with algorithm
Unit 1-problem solving with algorithmUnit 1-problem solving with algorithm
Unit 1-problem solving with algorithm
 
BP206 - Let's Give Your LotusScript a Tune-Up
BP206 - Let's Give Your LotusScript a Tune-Up BP206 - Let's Give Your LotusScript a Tune-Up
BP206 - Let's Give Your LotusScript a Tune-Up
 
Introduction To Programming
Introduction To ProgrammingIntroduction To Programming
Introduction To Programming
 
Functional pogramming hl overview
Functional pogramming hl overviewFunctional pogramming hl overview
Functional pogramming hl overview
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
 
The Power of Composition
The Power of CompositionThe Power of Composition
The Power of Composition
 
4. programing 101
4. programing 1014. programing 101
4. programing 101
 
Help with Pyhon Programming Homework
Help with Pyhon Programming HomeworkHelp with Pyhon Programming Homework
Help with Pyhon Programming Homework
 
Chapter 2- Prog101.ppt
Chapter 2- Prog101.pptChapter 2- Prog101.ppt
Chapter 2- Prog101.ppt
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Reinventing the Transaction Script (NDC London 2020)
Reinventing the Transaction Script (NDC London 2020)Reinventing the Transaction Script (NDC London 2020)
Reinventing the Transaction Script (NDC London 2020)
 
resolvendo problemas de comunicação em equipes distribuídas com bdd
resolvendo problemas de comunicação em equipes distribuídas com bddresolvendo problemas de comunicação em equipes distribuídas com bdd
resolvendo problemas de comunicação em equipes distribuídas com bdd
 
C++ lecture 01
C++   lecture 01C++   lecture 01
C++ lecture 01
 

Mehr von nicky_walters

Mehr von nicky_walters (13)

Pseudocode flowcharts
Pseudocode flowchartsPseudocode flowcharts
Pseudocode flowcharts
 
Data types vbnet
Data types vbnetData types vbnet
Data types vbnet
 
Data types vbnet
Data types vbnetData types vbnet
Data types vbnet
 
Ndu06 typesof language
Ndu06 typesof languageNdu06 typesof language
Ndu06 typesof language
 
Event driventheory
Event driventheoryEvent driventheory
Event driventheory
 
Simple debugging
Simple debuggingSimple debugging
Simple debugging
 
Debugging
DebuggingDebugging
Debugging
 
Using loops
Using loopsUsing loops
Using loops
 
Input output
Input outputInput output
Input output
 
Controls
ControlsControls
Controls
 
Decisions
DecisionsDecisions
Decisions
 
Intro to visual studio 2008
Intro to visual studio 2008Intro to visual studio 2008
Intro to visual studio 2008
 
Input output
Input outputInput output
Input output
 

Algorithms

  • 1. Algorithms for Program Design 1
  • 2. Process Modelling Process modelling is performed during the design stage of developing a new system. Data Flow Diagrams - show WHAT the new system must be able to do. Process Specification - provides details of HOW the required functionality is achieved. Various techniques used to clarify procedures Structure Diagrams Flow Charts Pseudocode / Structured English Provides the logical design for a computer algorithm 2
  • 3. Start Start Flow Charts Subtotal = 00 Subtotal = • Not to be confused with Data Flow Diagrams (DFDs) VAT = 1.175 VAT = 1.175 Shows steps required to achieve the correct outcome Input: ItemPrice Input: ItemPrice Flow charts provide a graphical representation of an algorithm Subtotal = Subtotal + Subtotal = Subtotal + • Can become complex and hard to follow ItemPrice ItemPrice • Best used to give overview of functionality. Pseudocode provides a non-technical no End of Item list? End of Item list? description of an algorithm • More detailed and closely related to yes programming code Total = Subtotal **VAT Total = Subtotal VAT Structure diagrams are useful to show a hierarchical overview of program modules Output: Output: • Helps to identify how the main project “Total Price = £” (Total) “Total Price = £” (Total) components will be created • Input - Processing - Output Stop Stop 3
  • 4. Pseudocode Pseudocode is a technique used during the design stage of developing a program. Used to translate the users requirements into a into a complete sequence of unambiguous, logical steps. It is written in Structured English to describe the system operations accurately and precisely, including all the steps need to code the program. Can be understood by any programmer & coded into any language. 4
  • 5. How to….Create an Algorithm Start with a statement of the user’s needs Then write a program specification Then write out in sentences what the program needs to do at each step All of the time, consider how a computer runs an event driven program INPUT – PROCESS – OUTPUT 5
  • 6. How to ... Pseudocode Starting with general sentences (Structured English) Remove as many of the extra words as you can - just leave the bare minimum If values are being entered - input: use the term “read in” or “get”….. For any processing or calculations use the logical operators + - * / < > = “True”, “False” If results are being displayed - output: use the term “print” The final pseudocode should be language independent, but must avoid any ambiguity. 6
  • 7. Example: Description of the stages of a program for adding two numbers and displaying the result: The user types in Number1 The user types in Number2 The program adds Number1 and Number2 The program displays the Total on the screen This isn’t written in pseudocode quite yet…… 7
  • 8. Example: Read in Number1 Read in Number2 Total = Number1 + Number2 Print (Total) Now this is like program code Because of this it is called pseudocode Structured English is what it is written in 8
  • 10. Example: Verify Product For each Ordered Product Get Product(CatNo), Ordered(CatNo) If Product(CatNo) = Ordered (CatNo) Then Get Product (Level), Ordered (Quantity), If Product (Level) >= Ordered (Quantity) Then Order accepted = True Else Order accepted = False End If Else Print Invalid Product No End If Next Product Print confirmed order 10
  • 12. Example: Credit Card Authorisation START Bank connection GET Total due, Card type, Card number, Expiry date GET Stolen cards list IF Stolen = True THEN Print “Retain card and destroy” ELSE LOOP WHILE Counter < 3 AND PIN = False Increment Counter GET PIN IF PIN = True THEN GET Limit, Balance IF Total Due < Limit - Balance THEN GET Ref (Transaction) Balance = Balance + Total Due PRINT “Transaction authorised” & Ref ELSE Authorised = False PRINT “Insufficient funds available” END IF EXIT Bank connection END IF END LOOP PRINT “Incorrect PIN - Retain card and refer to bank” END IF EXIT Bank connection 12