Professional Documents
Culture Documents
2.1.1 Problem-Solving and Design
2.1.1 Problem-Solving and Design
Video
Syllabus criteria
● flowcharts, pseudocode, library routines and subroutines
● work out the purpose of a given algorithm ( only practice questions)
● suggest and apply suitable test data
pseudocode
● Simple way of
representing an
algorithm using
english-like words
● Look at the
pseudocode
structure -
document posted on
google classroom
flowcharts
● Graphically illustrate an
algorithm.
Video
Library routines
● A library routine is a set of programming instructions for a given task that is already
available for use.
● It is pre-tested and usually performs a task that is frequently required.
● Already present in the software .
● Saves a lot of time for the programmer
E.g. in Python Pygame or Pygame Zero are libraries that allow programmers to write games
in Python. They provide easy to use functions and structures to create a Window, Sprites
and carry out common tasks like detecting collision and drawing the screen.
Video
Subroutines ( Procedures and Functions)
● A Subroutine is a set of programming instructions for a given task (sub system) - called from the main
program
● It could be a task that is repeated a lot
● It is created by the user to divide the system into smaller sub-systems and it saves time and improves
efficiency.
● Subroutines can be a : 'procedures' or 'functions'
Video
Procedures and Functions
Return Value - An answer/ result returned to the main program
Procedure: A subroutine that does not return a value to the main program
Video
Test data for testing code
● In order to determine whether a solution is working as it should, it needs to be
tested.
● We enter different types of data into the algorithm to see that it is error free.
Normal data - data that should be accepted as input to the algorithm and cause no errors
Extreme/Boundary - largest and smallest data that can be accepted by the system ; at each
boundary two values are required, one value is accepted and the other value is rejected.
Erroneous/ Abnormal data - data that is not suitable and should be rejected as input to the
system
Video
Syllabus criteria
• understand the need for validation and verification checks to be made on
input data
• use trace tables to find the value of variables at each step in an algorithm
Video
Verification
Verification - checking that data has been accurately copied onto the computer or transferred from one
part of a computer system to another.
Video
Drawing a Trace Table
INPUT x Trace the opposite algorithm with the following inputs:
5,2
INPUT y
Sum = 0
5 2 0 5
Sum = Sum + x
1 10
NEXT i
2 15
OUTPUT i , Sum 2 15
Video
Trace tables
● A TRACE TABLE can be used to record the results from each step in an
algorithm;
● it is used to record the value of an item (variable ) each time that it changes.
● It can help detect errors in the algorithm
Effectiveness of a solution
New Curriculum
Add on content
Understand the program development life cycle
The various stages are:
1) Analysis
● to find out what is required before solving the problem
● Uses abstraction tools and decomposition tools to find the requirements
● Abstraction - keeping the key details and discarding the unnecessary details
● Decomposition - breaking problem in into smaller parts
2) Design
● to create a blueprint / structure of the solution to be created
● Methods used - structure diagrams, flowcharts and pseudocode
3) Coding
● The various modules of a program are written using a programming language
● The modules are tested and then changes are made and then tested again - till module performs
perfectly . This is called iterative testing
Understand the program development life cycle
The various stages are:
4) Testing
● The complete program is run using various sets of test data to see if all parts of the program are
working.
Video
Decomposing a problem
● Any problem on a computer system can be decomposed in the following four parts:
○ Inputs - data that is entered into the system
○ Processes - tasks done by the system using the input data and any other stored data
○ Outputs - information that needs to be displayed
○ Storage - data that needs to be stored in the computer memory for future use
Video
Methods used to design and construct a solution to a problem
Examples:
Video
Standard programs :
1. Totaling
2. Counting
Standard programs :
3. Maximum, minimum - there are 2 methods
Video
Standard programs :
5. Bubble sort - sorting a list in ascending or descending order
- Each element in the list is compared with the element next to it.
- If in incorrect order, the positions are swapped
- Go though the entire list again and repeat this process till there are no more swaps.
Video