With examples of program:
• Range check + checks upper and lower boundaries + to make sure the input is between
sensible limits
• Type check + ensures the data inputted is of the correct data type + to make sure the
input is an integer/string/float/Boolean
• Presence check + ensure a value is inputted + not left blank
• Length check + limits number of characters that can be input + checks minimum and
maximum string length
• Format check - ensures the data inputted follows a set pattern + checks input consists
of only a certain number of digits
• Look up / table check + ensures that the data inputted is one from an allowed set of
values + checking that the input is one of the values inclusive
Types of errors
• Syntax error + error in the rules and grammar of the program language + program does
not fully run + program does not fully execute
• Logic error + produces incorrect/unexpected output + program still runs + program
does not crash
Sorting algorithms
• Purpose of temporary variable in sorting algorithms is to store and hold a value/data +
so the value can be swapped/overwritten + without being lost
• Insertion sort + starts on the second value + inserts values one at a time into correct
position until all items checked + inserts value once + creates a sorted array within an
array + completes insertion sort in one pass through the array + more efficient/faster
than bubble sort because fewer iterations/comparisons on average
• Bubble sort + compares and swaps pairs of values + value is repeatedly moved and
swapped until in correct position + needs multiple passes + will complete a final iteration
once sorted to check that no swaps are needed + end of array becomes sorted first +
moves highest value to the top + easier/faster to implement than other sorting
algorithms + less efficient/slower than insertion sort on large sets of values due to more
iterations/comparisons on average
, • Both bubble sort and insertion sort + both start by comparing first two values + both
produce a sorted list + both work from left to right + both compare pairs of values +
both swap values + both use loops + both may need multiple passes + both require a
temporary variable + both typically less efficient + both slower than merge sort + both
slow for large unsorted lists
• Binary search + select middle number + check if selected number is equal to target
number + if equal then end search + else if searched number is larger then discard left
half + if searched number is smaller then discard right half + repeat until number found +
repeat until remaining list is 0 and number not found
• Linear search + starting with the first value + check all values in order
• Binary search + more efficient than linear search + less time taken for larger lists
• Merge sort + list split into individual elements + individual elements merged into
sorted lists of size two + lists of size two merged into sorted lists of size four + lists of size
four merged into final sorted list + consistent running time for lists of same length +
doesn’t depend on how ordered original list is + faster/quicker to sort more large/more
unordered lists + more efficient than bubble/insertion sorts
Testing
• Testing important + checks program works as intended + checks whether program
gives correct output + checks for errors so errors can be identified + ensures
improvements can be made as a result of testing to ensure no problems + for defensive
design considerations to anticipate misuse
• Final/terminal testing + completed at the end of the development of the program +
tests the product as a whole
• Iterative testing + completed during development + after each module is completed +
tests each module in isolation