Task 1: Investigate flowchart symbols

advertisement

Algorithm & Flowchart Solutions

Task 1: Investigate flowchart symbols

The Shorter Oxford defines it as "a diagram showing the movement or action of persons or things in any complex system".

Task 2: Identify algorithm pre-conditions

The goal is to find the largest number in a list of unsorted random numbers.

The algorithm would fail if there were no numbers in the list. Also, what if the list was not numbers but text?

Task 3: Write an algorithm demonstrating sequence

Flowchart: Pseudocode:

READ number1

READ number2

SET result = number1

SET result = result * number2

SET result = result + 27

DISPLAY result

© State of New South Wales, Department of Education and Training, 2006

Algorithm & Flowchart Solutions

Task 4: Draw a flowchart demonstrating sequence

© State of New South Wales, Department of Education and Training, 2006

Algorithm & Flowchart Solutions

Task 5: Write an algorithm demonstrating selection

Pseudocode:

READ testmark

IF testmark > 82 THEN

Display 'Distinction'

ELSE IF testmark > 69 THEN

Display 'Credit'

ELSE IF testmark greater than 49 THEN

Display 'Pass'

ELSE

Display 'Fail'

ENDIF

Flowchart:

© State of New South Wales, Department of Education and Training, 2006

Algorithm & Flowchart Solutions

Task 6: Draw a flowchart demonstrating selection

1.

Draw a flowchart that determines whether the game AI attacks the opponent or not, based on the following conditions: a) If the opponent has developed a barracks, but no soldiers then the AI will not attack, however; b) If the opponent has developed a barracks and produced solders then the AI will attack. c) If the twenty minutes of game time elapses, then the AI will attack anyway.

© State of New South Wales, Department of Education and Training, 2006

Algorithm & Flowchart Solutions

Task 7: Write an algorithm demonstrating iteration

Flowchart: Pseudocode:

READ maxNum

SET total = 0

FOR count = 1 TO maxNum DO

SET total = total + count

ENDFOR

DISPLAY total

OR

READ maxNum

SET total = 0

SET count = 1

WHILE count <= maxNum DO

SET total = total + count

SET count = count + 1

ENDWHILE

DISPLAY total

© State of New South Wales, Department of Education and Training, 2006

Algorithm & Flowchart Solutions

Task 8: Draw a flowchart demonstrating iteration

© State of New South Wales, Department of Education and Training, 2006

Download