Sequences Modules08

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

1 comments

Comments 1 - 1 of 1 previous next Post a comment

Post a comment
Embed Video
Edit your comment Cancel

Favorites, Groups & Events

Sequences Modules08 - Presentation Transcript

  1. Sequences, Modules and Variables David Millard (dem@ecs.soton.ac.uk)
  2. Overview
    • Pseudocode
    • Flowcharts
    • What are Modules?
    • Variables
    • Parameters
  3. Pseudocode
    • “ 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”
    • - Wikipedia
    • “ A notation resembling a simplified programming language, used in program design; esp. one consisting of expressions in natural language syntactically structured like a programming language”
    • - Oxford English Dictionary
  4. Pseudocode
    • “ 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”
    • - Wikipedia
    • “ A notation resembling a simplified programming language , used in program design; esp. one consisting of expressions in natural language syntactically structured like a programming language”
    • - Oxford English Dictionary
  5. Pseudocode
    • “ 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”
    • - Wikipedia
    • “ A notation resembling a simplified programming language , used in program design; esp. one consisting of expressions in natural language syntactically structured like a programming language”
    • - Oxford English Dictionary
  6. Pseudocode
    • “ 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”
    • - Wikipedia
    • “ A notation resembling a simplified programming language , used in program design; esp. one consisting of expressions in natural language syntactically structured like a programming language ”
    • - Oxford English Dictionary
  7. Example: Making a Cup of Tea
  8. Example: Making a Cup of Tea
    • Make a Cup of Tea
    • Get Cup
    • Get Kettle
    • Get Tea
    • Get Milk
    • Get Sugar Lumps
    • Empty Kettle
    • Fill Kettle with Water
    • Switch Kettle on
    • Wait until Kettle Boils
    • Put Tea in Pot
    • Put Boiling Water in Pot
    • Wait 2 Minutes
    • Put Milk in Cup
    • Pour Tea in Cup
    • Put 1 Sugar Lump in Cup
    • Stir Tea in Cup
    • Give Cup of Tea to User
    Pseudocode Assumptions?
  9. Example: Making a Cup of Tea
    • Make a Cup of Tea
    • Get Cup
    • Get Kettle
    • Get Tea
    • Get Milk
    • Get Sugar Lumps
    • Empty Kettle
    • Fill Kettle with Water
    • Switch Kettle on
    • Wait until Kettle Boils
    • Put Tea in Pot
    • Put Boiling Water in Pot
    • Wait 2 Minutes
    • Put Milk in Cup
    • Pour Tea in Cup
    • Put 1 Sugar Lump in Cup
    • Stir Tea in Cup
    • Give Cup of Tea to User
    Pseudocode
    • Assumptions:
    • Electric Kettle
    • User wants Milk and Sugar
    • Only making 1 cup of tea
    • Nothing goes wrong!
  10. Modules
    • Modules break an algorithm into logical parts
      • Helps with Clarity and Understandability
    • Modules can be reused
      • Within the same algorithm
      • In a different algorithm
    • In Programming Modules can be called:
      • Sub-routines (in older languages)
      • Functions (in procedural languages like C)
      • Methods (in object oriented languages like Java)
  11. Example: Making a Cup of Tea
    • Make a Cup of Tea
    • Get Cup
    • Get Kettle
    • Get Tea
    • Get Milk
    • Get Sugar Lumps
    • Empty Kettle
    • Fill Kettle with Water
    • Switch Kettle on
    • Wait until Kettle Boils
    • Put Tea in Pot
    • Put Boiling Water in Pot
    • Wait 2 Minutes
    • Put Milk in Cup
    • Pour Tea in Cup
    • Put 1 Sugar Lump in Cup
    • Stir Tea in Cup
    • Give Cup of Tea to User
  12. Example: Making a Cup of Tea
    • Make a Cup of Tea
    • Get Cup
    • Get Kettle
    • Get Tea
    • Get Milk
    • Get Sugar Lumps
    • Empty Kettle
    • Fill Kettle with Water
    • Switch Kettle on
    • Wait until Kettle Boils
    • Put Tea in Pot
    • Put Boiling Water in Pot
    • Wait 2 Minutes
    • Put Milk in Cup
    • Pour Tea in Cup
    • Put 1 Sugar Lump in Cup
    • Stir Tea in Cup
    • Give Cup of Tea to User
    Fetch Utensils and Ingredients Boil Water in Kettle Make Tea in Pot Add Tea, Milk and Sugar to Cup
  13. Example: Making a Cup of Tea
    • Make a Cup of Tea
    • Fetch Utensils and Ingredients
    • Boil Water in Kettle
    • Make Tea in Pot
    • Add Tea, Milk and Sugar to Cup
    • Give Cup of Tea to User
    Fetch Utensils and Ingredients Get Cup Get Kettle Get Tea Get Milk Get Sugar Lumps Boil Water in Kettle Empty Kettle Fill Kettle with Water Switch Kettle on Wait until Kettle Boils Make Tea in Pot Put Tea in Pot Put Boiling Water in Pot Wait 2 Minutes Add Tea, Milk and Sugar to Cup Put Milk in Cup Pour Tea in Cup Put 1 Sugar Lump in Cup Stir Tea in Cup Give Cup of Tea to User
  14. Variables
    • Variables are named items in an algorithm that can take a variable value
    • For example when calculating VAT
      • Tax, Value of Product, and Total Cost are variables
      • Pay for Bike Including Tax
      • Tax = 17.5
      • Value of Product = 200
      • Total Cost = Value of Product * (100 + Tax)/100
      • Customer pays Total Cost
  15. Parameters
    • Parameters are variables that are passed to a module and are used inside like variables
    • For example when calculating VAT
      • Value of Bike is a Parameter, Tax and Total Cost are Variables
      • Buy New Bike
      • Select Bike
      • Pay for Bike Including Tax (200)
      • Take Bike Home
      • Pay for Bike Including Tax (Value of Bike)
      • Tax = 17.5
      • Total Cost = Value of Bike * (100 + Tax)/100
      • Customer pays Total Cost
  16. Where are the Variables and Parameters?
    • Make a Cup of Tea
    • Fetch Utensils and Ingredients
    • Boil Water in Kettle
    • Make Tea in Pot
    • Add Tea, Milk and Sugar to Cup
    • Give Cup of Tea to User
    Fetch Utensils and Ingredients Get Cup Get Kettle Get Tea Get Milk Get Sugar Lumps Boil Water in Kettle Empty Kettle Fill Kettle with Water Switch Kettle on Wait until Kettle Boils Make Tea in Pot Put Tea in Pot Put Boiling Water in Pot Wait 2 Minutes Add Tea, Milk and Sugar to Cup Put Milk in Cup Pour Tea in Cup Put 1 Sugar Lumps in Cup Stir Tea in Cup Give Cup of Tea to User
  17. Where are the Variables and Parameters?
    • Make a Cup of Tea
    • Fetch Utensils and Ingredients
    • Boil Water in Kettle
    • Make Tea in Pot
    • Add Tea, Milk and Sugar to Cup
    • Give Cup of Tea to User
    Fetch Utensils and Ingredients Get Cup Get Kettle Get Tea Get Milk Get Sugar Lumps Boil Water in Kettle Empty Kettle Fill Kettle with Water Switch Kettle on Wait until Kettle Boils Make Tea in Pot Put Tea in Pot Put Boiling Water in Pot Wait 2 Minutes Add Tea, Milk and Sugar to Cup Put Milk in Cup Pour Tea in Cup Put 1 Sugar Lumps in Cup Stir Tea in Cup Give Cup of Tea to User
  18. Where are the Variables and Parameters?
    • Make a Cup of Tea
    • Fetch Utensils and Ingredients
    • Boil Water in Kettle
    • Make Tea in Pot ( 2 )
    • Add Tea, Milk and Sugar to Cup ( 1 )
    • Give Cup of Tea to User
    Fetch Utensils and Ingredients Get Cup Get Kettle Get Tea Get Milk Get Sugar Lumps Boil Water in Kettle Empty Kettle Fill Kettle with Water Switch Kettle on Wait until Kettle Boils Make Tea in Pot ( n_min ) Put Tea in Pot Put Boiling Water in Pot Wait n_min Minutes Add Tea, Milk and Sugar to Cup ( n_sugars ) Put Milk in Cup Pour Tea in Cup Put n_sugars Sugar Lumps in Cup Stir Tea in Cup Give Cup of Tea to User
  19. Summary
    • Pseudocode
      • High level description of algorithm…
      • … intended for human reading…
      • … but structured like a programming language
    • Modules (subroutines/ functions/ methods)
      • Break down bigger algorithms into chunks
      • Improves Clarity and Reuse
    • Variables and Parameters
      • Are named things with a value (like in algebra)
      • Can make algorithms more flexible
      • Can also improve Reuse

+ hoosfooshoosfoos, 2 years ago

custom

569 views, 0 favs, 1 embeds more stats

A brief introduction to how algorithms can be broke more

More info about this document

© All Rights Reserved

Go to text version

  • Total Views 569
    • 494 on SlideShare
    • 75 from embeds
  • Comments 1
  • Favorites 0
  • Downloads 11
Most viewed embeds
  • 75 views on https://secure.ecs.soton.ac.uk

more

All embeds
  • 75 views on https://secure.ecs.soton.ac.uk

less

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

Cancel
File a copyright complaint
Having problems? Go to our helpdesk?

Categories