Writing Algorithms
Writing Algorithms
[2]
A flowchart is used to describe the logical steps needed to solve a problem in a diagrammatic way.
Pseudocode is used to describe the logical steps needed to solve a problem using text, written in a way that resembles programming languages.
3. Write an algorithm in pseudocode which asks for the user to input 2 numbers and then outputs their sum. [3]
INPUT number1
INPUT number2
answer = number1 + number2
OUTPUT answer
Question Zone 4-6
4. Create a flowchart which shows the logic required to ask the user to input a word, check its length and output one of two messages depending on its
length. If it is longer than 8 characters, “It’s a long word” should be outputted, otherwise “It’s a short word” should be outputted. [6]
5. “Effective algorithms are independent of any language”. Explain the meaning of this statement [2]
Question Zone 7-9
6. Write an algorithm in pseudocode which shows the logic required to repeatedly ask the user to enter a password until it matches the string “pa$$word”. [5]
set_password = “pa$$word”
INPUT password
WHILE password != set_password:
INPUT password
7. Discuss the two methods of writing algorithms and explain which you think is the most effective for an experienced software designer. [4]
- Flowcharts are graphical and visually show decisions, branching and iterations.
- Could argue that it is suited to focusing on the overall logic of the problem.
- Could argue that it may be preferred by less-technical coders for complex problems
- Pseudocode is more linear in its presentation (decisions/branching/iterations are less clear) and resemble the way programming languages are
written.
- Could argue that it is more easily merged / converted into real code than flowcharts are.