Systematic Approach to Problem Solving (AQA GCSE Computer Science)

Revision Note

Test yourself
  • 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

users = [

["Dave", "Un1corn$"],

["George", "B@tman#1"],

["Elizabeth", "Coffee!!"],

["Henry", "Walking&123"]

]

# Ask the user for a name to search for

name_to_find = input("Enter a name to find: ")

# Search for the name in the first column of the list of users 

found = False

for i in range(len(users)):

             if name_to_find == users[i][0]:
             
                 found = True
             
                 password_to_check = input("Enter the password: ")
             
                 if password_to_check == users[i][1]:
             
                     print("Password correct. Access granted.")
                     break
             
                 else:
             
                     print("Incorrect password. Access denied.")
                     break
             

if found == False:

             print("Name not found.")

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

Age ← INPUT()

IF age >= 18 THEN

   PRINT("Welcome to the site")

ELSE

    PRINT("Sorry, this site is for users 18 and over")

END IF

  • 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

Pseudocode

Fname ← INPUT()

Age ← INPUT()

IF age >= 18 THEN

   PRINT("Welcome to the site + fname")

ELSE

      PRINT("Sorry, this site is for users 18 and over")

END IF

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

print("Hello")

INPUT

Fname ← INPUT()

SELECTION

IF num == 2 then

...

ELSE IF num < 4 then

...

ENDIF

FOR LOOPS

for i ← 1 to 10

...

 ENDFOR

WHILE LOOPS

while (i ≠ 11)

...

ENDWHILE

Examiner Tip

AQA have a pseudocode guide for students and teachers to use which will match the pseudocode in the exam papers.

Worked Example

flow-chart-question

Rewrite the flowchart as a pseudocode [4]
You must use Pseudocode

Answer

Pseudocode

INPUT price

IF price < 50 THEN

OUTPUT "Great choice!"

ELSE

OUTPUT "Way too expensive"

END IF

Program Code

  • Program code, unlike the generic pseudocode, is specific to a programming language

  • The accepted languages you can answer questions in are:

  • 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

flow-chart-symbols

Example

Flowchart

flow-chart-1
  • 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

flow-chart-2-1

Last updated:

You've read 0 of your 10 free revision notes

Unlock more, it's free!

Join the 100,000+ Students that ❤️ Save My Exams

the (exam) results speak for themselves:

Did this page help you?

James Woodhouse

Author: James Woodhouse

Expertise: Computer Science

James graduated from the University of Sunderland with a degree in ICT and Computing education. He has over 14 years of experience both teaching and leading in Computer Science, specialising in teaching GCSE and A-level. James has held various leadership roles, including Head of Computer Science and coordinator positions for Key Stage 3 and Key Stage 4. James has a keen interest in networking security and technologies aimed at preventing security breaches.

Lucy Kirkham

Author: Lucy Kirkham

Expertise: Head of STEM

Lucy has been a passionate Maths teacher for over 12 years, teaching maths across the UK and abroad helping to engage, interest and develop confidence in the subject at all levels.Working as a Head of Department and then Director of Maths, Lucy has advised schools and academy trusts in both Scotland and the East Midlands, where her role was to support and coach teachers to improve Maths teaching for all.