C:S Notes 7
C:S Notes 7
                                                                                                        YOUR NOTES
               IGCSE Computer Science CIE                                                                   
CONTENTS
7.1 Development Life Cycle
  Program Development Life Cycle - Analysis
  Program Development Life Cycle - Design
  Program Development Life Cycle - Coding
  Program Development Life Cycle - Testing
7.2 Algorithms
  Explaining Algorithms
7.3 Standard Methods
  Standard Methods
7.4 Validation and Testing
  Validation
  Test Data
  Trace Tables
7.5 Identifying Errors
  Identifying Errors
  Writing & Amending Algorithms
Page 1 of 40
                       © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                        Head to savemyexams.co.uk for more awesome resources
                                    Explaining Algorithms
     Algorithms can be written using flowcharts, pseudocode or high-level programming
     language code such as Python
     The purpose of an algorithm is to achieve some goal. It isn’t always initially clear what the
     goal may be. By following the algorithm instructions, the purpose can become clear
           Exam Tip
               Comments in an algorithm or program usually describe why something has
               been done or provide useful information to the reader. Each line of code should
               otherwise be self-explanatory
     The purpose of the algorithm below is to add ten user-entered numbers together and
     output the total. The processes are:
         initializing three variables (Count, Number, Total)
         inputting a user number
         adding to two variables (Total, Count)
         repeating nine more times
         outputting the final Total value
Count ← 1
Number ← 0
Total ← 0
REPEAT
INPUT Number
Count ← Count + 1
OUTPUT Total
Page 2 of 40
                              © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                          Head to savemyexams.co.uk for more awesome resources
                                                                                                               YOUR NOTES
   Worked Example
                                                                                                                   
    The Pseudocode Algorithm shown has been written by a teacher to enter marks for
    the students in her class and then to apply some simple processing.
    Count ← 0
REPEAT
INPUT Score[Count]
IF Score[Count] >= 70
THEN
Grade[Count] ← "A"
ELSE
IF Score[Count] >= 60
THEN
Grade[Count] ← "B"
ELSE
IF Score[Count] >= 50
THEN
Grade[Count] ← "C"
ELSE
IF Score[Count] >= 40
THEN
Grade[Count] ← "D"
ELSE
IF Score[Count] >= 30
THEN
Grade[Count] ← "E"
ELSE
Grade[Count] ← "F"
ENDIF
ENDIF
Page 3 of 40
                              © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                              Head to savemyexams.co.uk for more awesome resources
ENDIF
Count ← Count + 1
UNTIL Count = 30
Page 4 of 40
                    © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                              Head to savemyexams.co.uk for more awesome resources
                                                Linear Search
     The linear search is a standard algorithm used to find elements in an unordered list. The list
     is searched sequentially and systematically from the start to the end one element at a time,
     comparing each element to the value being searched for
          If the value is found the algorithm outputs where it was found in the list
          If the value is not found it outputs a message stating it is not in the list
     An example of using a linear search would be looking for a specific student name in a list or
     searching for a supermarket item in a shopping list
INPUT Number
Found ← FALSE
Index ←1
REPEAT
IF Number = Mylist[Index]
THEN
Found ← TRUE
ELSE
Counter ← Counter + 1
ENDIF
Page 5 of 40
                                    © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                              Head to savemyexams.co.uk for more awesome resources
IF Found = TRUE
THEN
ELSE
ENDIF
Page 6 of 40
                                  © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                                    Head to savemyexams.co.uk for more awesome resources
Mylist ← [5, 9, 4, 2, 6, 7, 1, 2, 4, 3]
FirstElement ← 1
LastElement ← LENGTH(Mylist)
REPEAT
Swap ← FALSE
Page 7 of 40
                                          © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                                   Head to savemyexams.co.uk for more awesome resources
Temp ← Mylist[Index]
Mylist[Index] ← Mylist[Index + 1]
Mylist[Index + 1] ← Temp
Swap ← TRUE
ENDIF
NEXT Index
LastElement ← LastElement - 1
Page 8 of 40
                                    © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                           Head to savemyexams.co.uk for more awesome resources
INPUT ItemValue
NEXT Count
OUTPUT Total
Counting
     Counting works similarly to totalling except the count is incremented or decremented by a
     fixed value, usually 1, each time it iterates. Counting keeps track of the number of times an
     action has been performed. Many algorithms use counting, including the linear search and
     binary search to track which element is currently being considered
     The count is incremented and each pass number is output until fifty outputs have been
     produced
Count ← 0
DO
Count ← Count + 1
     The count is decremented from fifty until the count reaches zero. An output is produced for
     each pass
Count ← 50
DO
Count ← Count - 1
Page 9 of 40
                                 © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                            Head to savemyexams.co.uk for more awesome resources
Min ← Score[1]
THEN
Max ← ScoreSize[Count]
ENDIF
THEN
Min ← ScoreSize[Count]
ENDIF
Next Count
     In the above algorithm, the initial max and min are set to the first value in the list and the for
     loop starts at the second element instead of the first as the first value is the benchmark to
     compare all other items to
     If no value is larger than the initial max, then Max doesn’t change. If no value is smaller than
     the initial min, then Min doesn’t change
     The algorithm loops over each element asking whether the current value is larger than Max
     and whether it is smaller than Min. Max and Min adjust their values throughout the program
     depending on these conditions
     The program will eventually output the smallest and largest value in Min and Max
     respectively
     Average values (also known as the mean) involve totalling all the list values and then
     dividing by the number of values in the list
Total ← 0
NEXT Count
Page 10 of 40
                                  © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                             Head to savemyexams.co.uk for more awesome resources
                                            Identifying Errors
Errors can be identified in algorithms using trace tables as well as scanning and debugging code
manually
Two types of errors are as follows:
       Syntax error
                     Syntax refers to the grammar of language, that is, are the words in the right order
                     and is everything spelled correctly
                     Unlike programs written on computers, syntax errors in flowcharts and
                     pseudocode do not cause the algorithm to fail however they do make the code
                     more difficult to read and understand
                     Transcribing flowcharts and pseudocode to real programming code may cause
                     problems if it is difficult to read and understand said flowcharts and pseudocode
       Logical error
              Logical errors occur when the program finishes but produces the wrong output during
              or after
              Flowcharts and pseudocode, unlike real programs, do not crash when dry run,
              however may still produce logic errors by producing incorrect output
              Logical errors are the most difficult error to fix as developers must reconsider their
              logic and processes. If they do not understand the problem they cannot produce an
              accurate solution
       Below is an algorithm that asks the user to enter their age to determine what rated movie
       they could watch at the cinema
       There are syntax and logical errors with this pseudocode
OUTPUT Age
IF Age > 18
THEN
ELSE
IF Age > 15
THEN
Page 11 of 40
                                  © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                             Head to savemyexams.co.uk for more awesome resources
THEN
ELSE
IF Age < 9
THEN
ELSE
END IF
ENDIF
ENDIF
ENDIF
    Syntax and logic: OUTPUT Age and INPUT “Enter an age” are both syntax and logical errors
        Syntax: Age does not yet have a value so OUTPUT cannot display it while INPUT does
        not have a variable to store the data as strings cannot store data
        Logical: Both are the wrong way around. OUTPUT Age should be OUTPUT “Enter an
        age” and INPUT “Enter an age” should be INPUT Age
    Syntax: THEN is missing from the first IF statement
    Syntax: A quote is missing from the OUTPUT “You can watch a 15 movie”
    Logic: Age < 9 should be Age > 9 so that it follows the other IF statement logic
    Syntax: ENDIF is missing from the first IF statement
Page 12 of 40
                                  © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                 Head to savemyexams.co.uk for more awesome resources
                                                                                                        YOUR NOTES
   Worked Example
                                                                                                            
      1. An algorithm has been written in pseudocode to input some numbers. It only
         outputs any numbers that are greater than or equal to 100. The number 999 is
         not output and stops the algorithm.
    INPUT Number
    WHILE Numbers <> 999 DO
    IF Number > 100
    THEN
    OUTPUT Number
    ENDIF
    ENDWHILE
    OUTPUT Number
    (a) Identify the four errors in the pseudocode and suggest corrections.
                                                                                           [4]
                                                            Numbers should be Number [1]
                                          IF Number > 100 should be IF Number >= 100 [1]
    INPUT Number is missing from inside the loop, insert INPUT Number after the ENDIF
                                                                        statement [1]
                                    The final OUTPUT Number is not needed, remove it [1]
    (b) Write a pseudocode statement to change the corrected algorithm to output all
    numbers between 100 and 200 inclusive. You do not need to rewrite the whole
    algorithm
                                                                                           [2]
                            [1] for both ends of the range and correct inequality symbols
                                                                               [1] for the AND
Page 13 of 40
                       © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                      Head to savemyexams.co.uk for more awesome resources
                                         Abstraction
This is the act of removing unimportant details of the problem to focus on important elements.
An example of abstraction would be the London underground train route map; travellers do not
need to know the geographical layout of the routes, only that getting on at stop A will eventually
transport you to stop B
Page 14 of 40
                            © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                 Head to savemyexams.co.uk for more awesome resources
                                                                                                        YOUR NOTES
                                                                                                            
                                   Requirements
Identification of the problem: Before tackling a problem, it needs to be clearly understood
by everyone working on it. The overall goal of the solution needs to be agreed as well as any
constraints such as limited resources or requiring a platform specific solution
Requirements: To create a solution, a requirements document is created to define the
problem and break it down into clear, manageable, understandable parts by using
abstraction and decomposition. A requirements document labels each requirement, gives
it a description as well as success criteria which state how we know when the requirement
has been achieved
Page 15 of 40
                       © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                            Head to savemyexams.co.uk for more awesome resources
                                                 Validation
     Validation and verification are used to ensure input data is correct, reasonable and
     accurate
     Validation generally is about making sure data follows a set of specified rules created by
     the programmer. Verification is about double-checking input data to make sure it's what
     the user intended to enter
Validation
     Validation is the method of checking input data so that it is of an expected value and
     therefore accepted by the system
     Programmers create rules using code that automatically checks user input data to make
     sure the data is reasonable. If it is not reasonable then the data is rejected, usually with a
     message explaining why it was rejected and allowing the user to reenter the data
     The different types of validation rules or checks are as follows:
          Range checks
          Length checks
          Type checks
          Presence checks
          Format checks
          Check digits
     Each piece of data may require multiple different checks to be fully valid
Range check
     Range checks make sure the input data is a value between a user-defined minimum and
     maximum value, for example, a percentage being between 0 and 100 inclusive or a date in
     April is between 1 and 30 inclusive
OUTPUT “Enter a number between 0 and 100”
REPEAT
INPUT Number
THEN
ENDIF
Page 16 of 40
                                © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                              Head to savemyexams.co.uk for more awesome resources
REPEAT
INPUT Pin
IF LENGTH(Pin) <> 4
THEN
OUTPUT “Your pin number must be four characters in length, please try again”
ENDIF
UNTIL LENGTH(Pin) = 4
     Passwords usually have a specified range, for example, eight to twenty characters in
     length. If it does not fall within this range, it should be rejected
OUTPUT “Please enter a password between 8 and 20 characters”
REPEAT
INPUT Password
THEN
OUTPUT “Your password must be between 8 and 20 characters in length, please try again”
ENDIF
Type checks
     Type checks make sure the input data is of the correct data type. For example, someone's
     age should be an integer (a whole number) whereas their name should be a string (a bunch
     of characters)
OUTPUT “Enter an integer number”
REPEAT
INPUT Number
THEN
Page 17 of 40
                                   © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                           Head to savemyexams.co.uk for more awesome resources
Presence check
     Presence checks make sure that input data has been entered and that the input box has
     not been left empty
     A login system requires presence checks as both a username and password are required
     for authentication
OUTPUT “Enter your username”
REPEAT
INPUT Username
IF Username = “”
THEN
ENDIF
Format check
     Format checks make sure that input data is of a predefined pattern
     Identification codes e.g. AP1234 and dates are examples of patterns
     Format checks are done using pattern matching and string handling
     The algorithm below checks a six digit identification number against the format “XX9999”
     where X is an uppercase alphabetical letter and 9999 is a four digit number
     The first two characters are checked against a list of approved characters. The first
     character is compared one at a time to each valid character in the ValidChars array. If it finds
     a match it stops looping and sets ValidChar to True. The second character is then
     compared one at a time to each valid character in the ValidChars array. If it finds a match
     then it also stops looping and sets ValidChar to True
     Casting is used on the digits to turn the digit characters into numbers. Once the digits are
     considered a proper integer they can be checked to see if they are in the appropriate range
     of 0-9999
     If any of these checks fail then an appropriate message is output
INPUT IDNumber
IF LENGTH(IDNumber) <> 6
THEN
Page 18 of 40
                                 © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                                 Head to savemyexams.co.uk for more awesome resources
FirstChar ← SUBSTRING(IDNumber, 1, 1)
ValidChar ← False
Index ← 1
IF FirstChar = ValidChars[Index]
THEN
ValidChar ← True
ENDIF
Index ← Index + 1
ENDWHILE
IF ValidChar = False
THEN
ENDIF
SecondChar ← SUBSTRING(IDNumber, 2, 2)
ValidChar ← False
Index ← 1
IF SecondChar = ValidChars[Index]
THEN
ValidChar ← True
ENDIF
Index ← Index + 1
ENDWHILE
IF ValidChar = False
THEN
Page 19 of 40
                                    © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                                 Head to savemyexams.co.uk for more awesome resources
THEN
OUTPUT “Digits invalid. Enter four valid digits in the range 0000-9999”
ENDIF
Check digits
       Check digits are numerical values that are the final digit of a larger code such as a barcode
       or an International Standard Book Number (ISBN). They are calculated by applying an
       algorithm to the code and are then attached to the overall code
       Check digits help to identify errors in data entry such as mistyping, miscanning or
       misspeaking
            Such errors include missing or additional digits, swapped digits, mispronunciation of
            digits or simply an incorrect digit
Barcode ← “9780201379624”
Total ← 0
IF Index MOD 2 = 0
THEN
ELSE
ENDIF
NEXT Index
IF CheckDigit = Barcode[LENGTH(Barcode)]
THEN
ELSE
Page 20 of 40
                                     © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                  Head to savemyexams.co.uk for more awesome resources
Page 21 of 40
        © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                               Head to savemyexams.co.uk for more awesome resources
INPUT Password
INPUT ConfirmPassword
THEN
ENDIF
Visual check
     Visual checks involve the user visually checking the data on the screen. A popup or
     message then asks if the data is correct before proceeding. If it isn’t the user then enters
     the data again
REPEAT
INPUT Name
INPUT Answer
Page 22 of 40
                                  © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                   Head to savemyexams.co.uk for more awesome resources
                                                                                                          YOUR NOTES
   Worked Example
                                                                                                              
    Describe the purpose of validation and verification checks during data entry.
    Include an example for each.
                                                                                             [4]
    Validation check
                                                                            [1] for description:
        To test if the data entered is possible / reasonable / sensible
        A range check tests that data entered fits within specified values
                                                                               [1] for example:
                                                   Range / length / type / presence / format
    Verification check
                                                                            [1] for description:
        To test if the data input is the same as the data that was intended to be input
        A double entry check expects each item of data to be entered twice and
        compares both entries to check they are the same
                                                                               [1] for example:
                                                                          Visual / double entry
Page 23 of 40
                         © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                  Head to savemyexams.co.uk for more awesome resources
                                   Decomposition
  This is the act of breaking down a large problem into smaller, clear, manageable and
  understandable sub-parts. Sub-parts can be divided until they are easily solvable and
  cannot be broken down any further. An example of decomposition could be getting ready
  in the morning to go to school
        Step 1: Wake up
        Step 2: Get breakfast
        Step 3: Brush teeth
        Step 4: Put clothes on
        Step 5: Make sure the bag and school supplies are ready
        Step 6: Find transport to school e.g. walk, bus, car, bike, etc
  These steps could be further subdivided, for example, “Step 2: Get breakfast” would entail:
      Step 2.1 Get a bowl
      Step 2.2 Get cereal
      Step 2.3 Get milk
      Step 2.4 Get a spoon
      Step 2.5 Put cereal in a bowl
      And so on…
  Once the requirements document has been created, developers need to design the
  structure and algorithms to solve the problem:
       Structure charts are created to show the breakdown of tasks in a hierarchy
       Flowcharts may be created to visually show how tasks should be carried out
       Pseudocode is created, sometimes from flowcharts, to allow programmers to easily
       translate task instructions into programming code
  The design of a solution identifies what tasks need completing, how to complete the tasks
  and how each task works together with other tasks
  A computer system includes several components that work together: software, hardware,
  data, networking and people
  Systems can be broken down into sub-systems that can be further broken down into more
  sub-systems, until each sub-system has a single purpose. This decomposition is known as
  top-down design
Decomposing a system
  To create an overall system and solve a problem, it must first be broken down into
  subsystems that are easier to solve and create. The act of breaking down the problem is
  known as stepwise refinement
Page 24 of 40
                        © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                Head to savemyexams.co.uk for more awesome resources
Decomposing the problem this way creates smaller, more manageable and more easily                      YOUR NOTES
understandable sub-parts                                                                                   
Each sub-system can be assigned to a developer or group of developers who create
subroutines from these sub-systems. Each sub-system can then be created at the same
time, reducing development and testing time, especially on large projects
Decomposing the system using stepwise refinement requires developers to think about
four key areas:
     Inputs: data entered into the system
     Processes: subroutines and algorithms that turn inputs and stored data into outputs
     Outputs: data that is produced by the system, such as information on a screen or
     printed information
     Storage: data that is stored on a physical device, such as on a hard drive
To solve a problem all aspects must be thoroughly understood by the developers
There are many methods used to design and construct solutions. Three such methods are
illustrated below:
Page 25 of 40
                      © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                Head to savemyexams.co.uk for more awesome resources
Page 26 of 40
                      © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                 Head to savemyexams.co.uk for more awesome resources
                                                                                                        YOUR NOTES
   Worked Example
                                                                                                            
    A satellite navigation system is an example of a computer system that is made up
    of subsystems. Part of a satellite navigation system: allows the user to enter details
    for a new destination or select a previously saved destination and displays
    directions in the form of a visual map or as a list. Draw a structure diagram for this
    part of the satellite navigation system.
                                                                                             [4]
                                                                [1] for a hierarchical structure
                                                [1] for suitable names for the sub-systems
                                                                      [1] for identifiable inputs
                                                                    [1] for identifiable outputs
Page 27 of 40
                       © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                  Head to savemyexams.co.uk for more awesome resources
Page 28 of 40
                        © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                 Head to savemyexams.co.uk for more awesome resources
                                                                                                        YOUR NOTES
                                                                                                            
                                    Pseudocode
Pseudocode is a programming-like language that does not have syntax. It can be
considered “fake” code.
It uses english words and phrases to represent instructions and is very similar to
programming code but does not and cannot run on any computer
The purpose of pseudocode is to allow developers to understand how to create a program
regardless of the programming language used to implement the solution
While pseudocode has no specific syntax, it is important to stick to a consistent style. This
will make it easier and quicker for programmers to read and create programs from the
pseudocode
      Examples of a consistent style can include:
          Keywords are written in capital letters e.g. INPUT, OUTPUT, IF, THEN, ELSE
          Variable and subroutine names start with capital letters e.g. Age, Name, Date,
          CalculateArea, Sortlist
          Indentation can be used for iteration and selection
Page 29 of 40
                       © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                   Head to savemyexams.co.uk for more awesome resources
                                        Test Data
Suggesting and applying suitable test data
  Before a system is used, each sub-system must be tested to ensure it works correctly and
  interacts correctly with other sub-systems
  Programs are tested by running them on a computing device while pseudocode and
  flowcharts must be dry run manually. Both require suitably chosen and different sets of test
  data. The outputs are then compared to the expected output to check if the algorithm
  works as intended
  Test data comes in several generic types:
       Normal
          Normal test data is data that a system would be expected to handle on a day-to-
          day basis, be accepted by the algorithm and produce expected results
          Examples could include entering people's names and addresses, phone
          numbers, student grades as a percentage, etc
          Student percentage grades could involve test data such as: 34, 41, 56, 78, 12, 92
      Abnormal
          Also known as erroneous data, abnormal data is data that is expected to fail and
          should be rejected by the system. This is used to prove that the system works
          correctly by rejecting incorrect data
          Examples of abnormal data would be entering numbers instead of someone's
          name, or entering text instead of numbers
          Student percentage grades abnormal data could involve test data such as: abc,
          7&n, Harry, £300, <!%, etc
      Extreme
          Extreme test data is the maximum and minimum values of normal data that are
          accepted by the system
          Examples could include percentages (0 and 100), days in April (1 and 30) or the
          number of characters in a passwords range
                For an 8-20 character range password, a password of 8 characters and
                another of 20 characters would be tested
      Boundary
          Boundary test data is similar to extreme data except that the values on either side
          of the maximum and minimum values are tested
          The largest and smallest acceptable value is tested as well as the largest and
          smallest unacceptable value
          For example, a percentage boundary test would be 0 and -1 (for 0) and 100 and
          101 (for 100). For the days in April, 1 and 0 (for day 1) and 30 and 31 (for day 30)
          would be tested. For an 8-20 length password, an 8 and 7 character password
          would be tested as well as a 20 and 21 character password
Page 30 of 40
                         © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                Head to savemyexams.co.uk for more awesome resources
                                                                                                       YOUR NOTES
   Worked Example
                                                                                                           
    A programmer has written an algorithm to check that prices are less than $10.00
    These values are used as test data: 10.00 9.99 ten
    State why each value was chosen as test data.
                                                                                          [3]
      10.00 is boundary or abnormal data and should be rejected as it is out of range [1]
       9.99 is boundary, extreme and normal data and should be accepted as it is within
                                                                 the normal range [1]
            Ten is abnormal data and should be rejected as it is the wrong value type [1]
Page 31 of 40
                      © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                   Head to savemyexams.co.uk for more awesome resources
Page 32 of 40
                         © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                Head to savemyexams.co.uk for more awesome resources
Page 33 of 40
                      © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                 Head to savemyexams.co.uk for more awesome resources
                                   Writing Code
 Developers begin programming modules in a suitable programming language that works
 together to provide an overall solution to the problem
 As each developer programs, they perform iterative testing. Iterative testing is where each
 module is tested and debugged thoroughly to make sure it interacts correctly with other
 modules and accepts data without crashing or causing any errors. Developers may need to
 retest modules as new modules are created and changed to make sure they continue to
 interact correctly and do not cause errors
Page 34 of 40
                       © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                    Head to savemyexams.co.uk for more awesome resources
                                       Trace Tables
  Trace tables are used to follow algorithms and make sure they perform the required task
  correctly. Test data is usually used in conjunction with a trace table to ensure the
  correctness of the algorithm. Manually tracing an algorithm with test data in this way is
  known as a dry run
  Trace tables can be used with flowcharts or pseudocode or even real code if necessary
  Trace tables can also be used to discover the purpose of an algorithm by showing output
  data and intermediary steps
  Trace tables record the state of the algorithm at each step or iteration. The state includes all
  variables that impact the algorithms output as well as the output itself
  A trace table is composed of columns where each variable and the output is a column
  Whenever a value changes or an output is produced the relevant column and row is
  updated to reflect the change
Page 35 of 40
                          © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                           Head to savemyexams.co.uk for more awesome resources
                                                                                                  YOUR NOTES
                                                                                                      
Page 36 of 40
                 © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                               Head to savemyexams.co.uk for more awesome resources
                8        9         9                                                                  YOUR NOTES
                9       12        12                                                                      
   Exam Tip
       When asked to identify the purpose of an algorithm in the exam, the variables
       listed will often be a single letter rather than a meaningful identifier
Page 37 of 40
                     © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                    Head to savemyexams.co.uk for more awesome resources
                                                                                                           YOUR NOTES
   Worked Example
                                                                                                               
    The flowchart represents an algorithm. The algorithm will terminate if –1 is entered.
    Complete the trace table for the input data: 50, 75, 99, 28, 82, 150, –1, 672, 80
                                                                                              [4]
        Value           Diff1      Diff2         Output
Page 38 of 40
                          © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
                                  Head to savemyexams.co.uk for more awesome resources
                                         Testing
 Once the overall program or set of programs is created, they are run many times using
 varying sets of test data. This ensures the program or programs work as intended as
 outlined in the initial requirements specification and design and rejects any invalid data that
 is input
 Examples of test data include alphanumeric sequences to test password validation
 routines. Such validation routines could be:
       A password must be between 8-20 characters
           Test data would be passwords of less than 8 characters or greater than 20
           characters
       A password must include only alphanumeric characters
           Test data would be passwords including non-alphanumeric symbols such as @, ?,
           #, !, $ or %, etc
Page 39 of 40
                        © 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
          Head to savemyexams.co.uk for more awesome resources
Page 40 of 40
© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers