knowt logo

Unit 9.2 Introduction to Algorithms

Aims

  • Understand what is meant by the terms input, process and output.

  • Understand what is meant by the term programming construct and how sequence, selection and iteration are used to structure code.

  • Understand what is meant by the term algorithm and the different ways to represent an algorithm.

  • Be able to write Structured English and draw flowcharts to represent algorithms.

Algorithm

Step by step description that define the logic programs will use for solving a problem or completing a task.

Developers use them to design logic/functionality of a program, then its implemented into specific programming language e.g. Python

STEPS MUST BE IN ORDER!!

Input, Process, Output

  • Input - Data entered, can be done manually or automatically (via a sensor), often stored in either a variable or constant so the algorithm can use it.

  • Process - Action carried out by the algorithm such as calculation, a condition to be checked following input or data manipulation (search/store etc.)

  • Output - response communicated back to user or sent to another part of the algorithm.

Programming Constructs

Algorithms are structured using programming constructs (aka programming control structure) which dictate the flow and order in which different instructions are run.

  • Sequence - Instructions run once and in the order they are written.

  • Selection - When the flow is interrupted and a condition is tested. Based on outcome, control is passed to another point in the algorithm.

  • Iteration - When one or more instructions are repeated.

Writing an Algorithm

Structured English

  • Uses Natural language approach

  • Standard English grammar to describe steps.

  • Clear and understandable especially to non-programmers.

  • e.g. writing step by step instructions to making a cup of coffee.

Flowcharts

  • Uses Graphical approach

  • Symbols for different parts. (see below)

  • Helpful visual aid to program flow and see how decisions made.

  • Format - Top to bottom, only use symbols below, breakdown as much as possible, use arrows to join and avoid crossing them.

Pseudocode

(See Unit 11)

  • Combines natural and structured programming language- like syntax.

  • Focuses on showing logic, without needing to stick to specific syntax rules within a programming language.,

Sequence Flowcharts

Instructions run once and one after another in order as written - ensure data has suitable identifier names - see example below.

Selection Flowcharts

When the flow is interrupted and a condition is tested, based on the outcome, control is then passed to onto another point in the algorithm.

Iteration Flowcharts

Where one or more instructions are repeated

Subroutine Flowchart

Subroutine - Flow temporarily transfers to another part of the flowchart designed to perform a particular task.

Helps to breakdown complex tasks into smaller manageable pieces and promote code reuse.

Unit 9.2 Introduction to Algorithms

Aims

  • Understand what is meant by the terms input, process and output.

  • Understand what is meant by the term programming construct and how sequence, selection and iteration are used to structure code.

  • Understand what is meant by the term algorithm and the different ways to represent an algorithm.

  • Be able to write Structured English and draw flowcharts to represent algorithms.

Algorithm

Step by step description that define the logic programs will use for solving a problem or completing a task.

Developers use them to design logic/functionality of a program, then its implemented into specific programming language e.g. Python

STEPS MUST BE IN ORDER!!

Input, Process, Output

  • Input - Data entered, can be done manually or automatically (via a sensor), often stored in either a variable or constant so the algorithm can use it.

  • Process - Action carried out by the algorithm such as calculation, a condition to be checked following input or data manipulation (search/store etc.)

  • Output - response communicated back to user or sent to another part of the algorithm.

Programming Constructs

Algorithms are structured using programming constructs (aka programming control structure) which dictate the flow and order in which different instructions are run.

  • Sequence - Instructions run once and in the order they are written.

  • Selection - When the flow is interrupted and a condition is tested. Based on outcome, control is passed to another point in the algorithm.

  • Iteration - When one or more instructions are repeated.

Writing an Algorithm

Structured English

  • Uses Natural language approach

  • Standard English grammar to describe steps.

  • Clear and understandable especially to non-programmers.

  • e.g. writing step by step instructions to making a cup of coffee.

Flowcharts

  • Uses Graphical approach

  • Symbols for different parts. (see below)

  • Helpful visual aid to program flow and see how decisions made.

  • Format - Top to bottom, only use symbols below, breakdown as much as possible, use arrows to join and avoid crossing them.

Pseudocode

(See Unit 11)

  • Combines natural and structured programming language- like syntax.

  • Focuses on showing logic, without needing to stick to specific syntax rules within a programming language.,

Sequence Flowcharts

Instructions run once and one after another in order as written - ensure data has suitable identifier names - see example below.

Selection Flowcharts

When the flow is interrupted and a condition is tested, based on the outcome, control is then passed to onto another point in the algorithm.

Iteration Flowcharts

Where one or more instructions are repeated

Subroutine Flowchart

Subroutine - Flow temporarily transfers to another part of the flowchart designed to perform a particular task.

Helps to breakdown complex tasks into smaller manageable pieces and promote code reuse.

robot