Systematic Approach to Problem Solving (AQA GCSE Computer Science)
Revision Note
When designing algorithms there are two main tools that can be used to describe them:
Pseudocode
Flowcharts
Examiner Tip
Remember, in the exam you will be expected to create, interpret, correct and refine algorithms in either flowcharts or AQA pseudocode
Systemic Approach
What is a systematic approach to problem solving?
A systematic approach means being able to take a logical approach and use algorithmic thinking to solve a problem
Some examples of systematic approaches include:
Solving a word search puzzle
Finding an item within a list
A good example of a systematic approach would be a program used to find a username and the matching password in a 2D list
In the example below, the 2D list has column 0 which stores the username and column 1 which stores the password
| [0] | [1] |
[0] | Dave | Un1corn$ |
[1] | George | B@tman#1 |
[2] | Elizabeth | Coffee!! |
[3] | Henry | Walking&123 |
To iterate through the list, an algorithm would have to take a systematic approach to look for the username entered by the user and then look in the column to the immediate right to find the password for that user
Python code |
---|
# Ask the user for a name to search for
# Search for the name in the first column of the list of users
|
Pseudocode
What is pseudocode?
Pseudocode is a text based tool that uses short English words/statements to describe an algorithm
Pseudocode is more structured than writing sentences in English, but is very flexible
Example
A casino would like a program that asks users to enter an age, if they are 18 or over they can enter the site, if not then they are given a suitable message
Pseudocode |
---|
|
The casino would like the algorithm refined so that the user also enter their first name and this is used to greet the user when they access the site
|
---|
|
What are the AQA pseudocode rules?
AQA use a standard style for pseudocode which has been around for many years and that is seen in AQA based exams to describe algorithms
Pseudocode has no official syntax so to keep exams consistent AQA have stuck with a common and well-used format
Examples
Function | AQA Pseudocode |
---|---|
OUTPUT |
|
INPUT |
|
SELECTION |
|
FOR LOOPS |
|
WHILE LOOPS |
|
Examiner Tip
AQA have a pseudocode guide for students and teachers to use which will match the pseudocode in the exam papers.
Worked Example
Rewrite the flowchart as a pseudocode [4]
You must use Pseudocode
Answer
Pseudocode |
|
Program Code
Program code, unlike the generic pseudocode, is specific to a programming language
The accepted languages you can answer questions in are:
C#
Python (version 3)
Exam questions will indicate the form of response expected, for example, pseudocode, program code or a flowchart
Worked Example
A programmer has written a C# program that asks the user to input two integers and then output which of the two integers is the largest. Complete the program by filling in the gaps using the information below. Each item in the table 3 should only be used once. [5]
Console.Write | num1 | num2 | output |
else | < | > | Else if |
string | double | int |
|
int num1;
________ num2;
Console.WriteLine("Enter a number: ");
num1 = int.Parse(Console.ReadLine());
Console.WriteLine("Enter another number: ");
num2 = int.Parse(Console.ReadLine());
if (num1 > num2)
{
Console.WriteLine("________is bigger.");
}
else if (num1________num2)
{
Console.WriteLine("________is bigger.");
}
________
{
Console.WriteLine("The numbers are equal.");
}
Answer
int num1;
int num2;
Console.WriteLine("Enter a number: ");
num1 = int.Parse(Console.ReadLine());
Console.WriteLine("Enter another number: ");
num2 = int.Parse(Console.ReadLine());
if (num1 > num2)
{
Console.WriteLine("num1 is bigger.");
}
else if (num1 < num2)
{
Console.WriteLine("num2 is bigger.");
}
else
{
Console.WriteLine("The numbers are equal.");
}
Flowcharts
What is a flowchart?
Flowcharts are a visual tool that uses shapes to represent different functions to describe an algorithm
Flowcharts show the data that is input and output, the processes that take place and any decisions or repetition
Lines are used to show the flow of control
Example
Flowchart |
---|
The casino would like the algorithm refined so that the user also enter their first name and this is used to greet the user when they access the site
Flowchart |
---|
Last updated:
You've read 0 of your 10 free revision notes
Unlock more, it's free!
Did this page help you?