Higher – Low-level Operations and Computer Architecture (Revision)

  • Virtual Machines: an emulation of a complete computer system which can be used to run alternative operating systems, or several copies of a single operating system
  • Emulators: software which duplicates the function of one computer system in another
  • Mobile Devices: features which require different types of software from conventional desktop systems eg touchscreen, pinch
  • Binary Representation of:
    • Integers – 163: 1 0 1 0 0 0 1 1
    • Negative Integers – -93: 1 0 1 0 0 0 1 1
    • Real numbers – 16.25: Mantissa & Exponent
      Stored using a mantissa (Larger = greater accuarcy) and an exponent (Larger = greater range)
    • Characters
      • ASCII (American Standard Code for Information Interchange) stores each letter, number or symbol using a number code from 0 to 127; ASCII uses eight bits (1s and 0s) to store each character
      • UNICODE 16bits, larger pool of characters
    • Instructions – represented by machine code as 0s and 1s
    • Vector Graphics – stored as a collection of mathematically determined shapes or objects; each object in the picture has properties such as width, height, fill colour, line colour eg
      <rect height=”96” width=”128” y=”3” x=”90” stroke-width=”6” stroke=”#cc0000” fill=”#ffcc33” id=”yellowrectangle”>
    • Bitmap Graphics – made up of a grid of pixels and stored in memory as a bit pattern of ones and zeros (calculations are mentioned later in this booklet)bm
    • Sound – sample rate (the number of times the value of the signal is recorded) and its bit depth (the number of bits used to store the sample)
    • Video – storing video requires both images and sound to be stored together; files will be very large as a result so compression is always used unless the video is being recorded for editing later; each frame in an MPEG video is compressed as a JPEG; the data that stays the same in successive frames is then removed
  • Processor: consists of several different parts:
    • the Arithmetic and Logic Unit which performs calculations;
    • the Control Unit which loads, decodes and executes instructions,
    • Registers which are small memory locations used by the processor
  • Cache: a faster kind of memory which stores copies of the data from frequently used main memory locations
  • Read Only Memory: Permanent memory; data is not lost when power switched off; this memory is very important and is used to store programs, like the operating system, for a long time
  • Random Access Memory: used to hold all data required for an active program or application to run; data is transferred from backing storage to RAM and held there until it is no longer required by the processor
  • Address Bus: identify the address of the location in cache or main memory that is to be read from or written to; uni-directional
  • Data Bus: will transfer data to/from the address that is held on the address bus; bi-directional; the amount of data that can be carried by the data bus depends on the word size (width of the data bus)
  • Interfaces: used to allow peripheral devices and hardware to connect to a computer system; allow for differences in speed and the way that data is handled by each peripheral device; an example is a USB; responsible for voltage conversion, status signals, data format conversion

National 5 – Low-level operations and computer architecture (Revision)

Units of storage:

8 bits = 1 byte
1024 bytes = 1 Kilobyte
1024 Kilobytes = 1 Megabyte
1024 Megabytes = 1 Gigabyte
1024 Gigabytes – 1 Terabyte
1024 Terabytes = 1 Petabyte

Translation of high-level program code to binary (machine code):

  • interpreters – translates source code to machine code line by line, spots errors more easily but takes longer.
  • compilers – translates the source code to machine code in one step, does not spot errors as line being typed, but more efficient. Creates a run time version (object code) that can’t be edited.

Use of binary to represent and store:

  • Real numbers uses mantissa & exponent – 0.256 X 105
    Mantissa = 256 Exponent = 5
  • Characters – ASCII allocates a different binary code to each letter, A = 00100001
  • Instructions, machine code – Binary instructions the processor can understand 10101011101
  • Graphics bit-mapped and vector
    • Bit-mapped graphics are made up of pixels
    • Vector graphics are described in text <rect width=”300″ height=”100″ style=”fill:rgb(0,0,255);stroke-width:3;stroke:rgb(0,0,0)”>

Basic computer architecture:

  • Processor (CU Ah Luv U Right)
    • Registers – temporary storage locations holding data being processed
    • ALU – deals with comparisons and arithmetic calculations
    • control unit – controls all other parts of the processor, ensures instructions are carried out in the correct order
  • Memory
    • Random Access Memory – temporary data storage only held as long as the computer is switched on.
    • Read only memory – Permanent memory not lost when the computer is switched off, can’t be changed.
  • Buses
    • data – carries data to and from the processor, memory and other devices. Bi-directional
    • address – carries address info from processor to the memory.
    • control – made up of a number of separate wires.
  • Interfaces
    • allows a processor to send and receive data to and from peripherals like printers, scanners, keyboards and projectors.
    • Bluetooth – Wireless
    • USB – Wired

Higher – Design Notations (Revision)

Make sure you read the N5 post on design notations for examples of Structure Diagrams, Flow Charts and Pseudocode.

Wire-Framing: A wireframe can show how a website will look and how its navigations structure works; can be as simple as a rough sketch or can be a detailed design showing colour combinations and images

Entity Relationship Diagrams

Relationships can be represented graphically using an Entity-Relationship (ER) diagram.

There are many different notations for ER diagrams, we will use crow’s foot notation.
• The names of entities are written in boxes joined by straight lines.
• At the “many” end the line forks.
• At the “one” end the line it judt joins the box.

ERD

Data dictionaries

A data dictionary is a design notation used to show the fields required in each table of a relational database, including field types, validation required, etc.

dd

Thank you to C O’Toole & A Madill from Braidhurst High School for allowing me to edit and publish this here.

National 5 – Design Notations (Revision)

N4

  • graphical to illustrate selection and iteration
  • other contemporary design notations

N5

  • pseudocode to exemplify programming constructs other contemporary design notations

 

Flow Chart
Flow Chart

You read a flow chart from the START block and follow the arrows (normally downward). In the example above you can see selection taking place in the first diamond, while the second diamond allows for iteration (repetition) to take place.

Structure Diagram
Structure Diagram

A structure diagram shows how the program is structured and in some cases how data can be passed from one part to the other.

Pseudocode

Pseudocode is an informal text description of the working of a program it is written using English words but not in a sentence structure. There are no syntax rules due to its informal nature, sometime they are numbered and sometimes they are not.

The SQA can sometimes refer to pseudocode in the exam when describing a program. However, they are often referring to Standard Reference Language. Rule of thumb, if they are asking you to read pseudocode it will be SRL, if they are asking you to write psuedocode then they mean psuedocode. Hopefully they will start using the correct terms in future papers.

Example 1

  1. set total = 0
  2. set count =0
  3. while count less than 10
  4.     get nextInput from user
  5.     add nextInput to total
  6.     add one to count
  7. end while
  8. display total/10

Example 2

get age from user
while age < 0 or age >130
    display error
    get age from user

display age

Higher – Algorithm Specification (Revision)

Input Validation: making sure that the data input by the user is acceptable e.g. in a suitable format and within the upper and lower limits of the data required by the software

RECEIVE userInput FROM (INTEGER) KEYBOARD
WHILE userInput < lowerLimit OR userInput > uperLimit DO
    SEND “Input must be between” & lowerLimit & “and” & upperLimit TO DISPLAY
    RECEIVE userInput FROM (INTEGER) KEYBOARD
END WHILE

Linear Search (efficient): sets a Boolean variable to false initially and uses an unconditional loop to set it to true when the item is found; the loop terminates when the item is found or the end of the array is reached

RECEIVE itemToFind FROM (INTEGER) KEYBOARD
SET found to false
SET arraySize to higestIndex
SET counter TO 0

WHILE counter <= arraySize AND found = false
    SET counter to counter + 1
    IF array[counter] = itemToFind THEN
        found=true
    END IF
END WHILE

IF found = true THEN
    SEND itemToFind & “found at position” & counter TO DISPLAY
ELSE
    SEND “Item not found” TO DISPLAY
END IF

Finding Minimum: sets an initial value to the first item in the array then compares it to the remaining items

SET maxiumValue to numbers[0]

FOR counter FROM 1 TO 9 DO
    IF maximumValue < numbers[counter] THEN
        SET maximumValue to numbers[counter]
    END IF
END FOR

SEND “The largest value was” & maximumValue to DISPLAY

Finding Maximum: sets an initial value to the first item in the array then compares it to the remaining items

SET miniumValue to numbers[0]

FOR counter FROM 1 TO 9 DO
    IF minimumValue > numbers[counter] THEN
        SET minimumValue to numbers[counter]
    END IF
END FOR

SEND “The smallest value was” & minimumValue to DISPLAY

Count Occurrences: sets a total to zero at the beginning and increments it as items are found to match the search item

RECEIVE itemToFind FROM (INTEGER) KEYBOARD
SET numberFound to 0

FOR EACH number FROM numbers DO
    IF number=itemToFind THEN
        SET numberFound to numberFound+1
    END IF
END FOR EACH

SEND “There were” & numberFound & “occurreneces of” & itemToFind & “in the list” TO DISPLAY

Thank you to C O’Toole & A Madill from Braidhurst High School for allowing me to edit and publish this here.

Higher – Testing and Documenting Solutions (Revision)

  •  Constructing a Test Plan: A set of test data which has been created to systematically and comprehensively to test the software; makes use of the following test data
    • normal – ensures the program works when used normally
    • extreme – ensures the program works when data is used that is on the boundaries of what is considered normal
    • exceptional – ensures a program can handle situations that it has not been designed to cope with; out with the boundaries
  • Comprehensive Testing: when every aspect of the software is tested
  • Syntax Error: a misspelling of a keyword or mistake in the structure of a program such as missing an ‘end if’
  • Logic Error: program will run but not as the programmer intended it to; for example when calculating the average it should be (a+b)/2 instead of a+b/2
  • Execution Error: an error occurs when the program is run, causing it to crash
  • Dry Runs: manual run through of pseudocode or source code of program, taking notes of the values of variables at various points in the process
  • Trace Tables: similar to the table used during a dry run but is often used to test an algorithm for a specific sub program
  • Breakpoints: a set point in a program where it will stop execution so that the values of variables can be examined

Thank you to C O’Toole & A Madill from Braidhurst High School for allowing me to edit and publish this here.

National 5 – Algorithm Specification (Revision)

Input validation – checking that what is entered by the user is acceptable.

The following program checks that age is a positive number.

1. SEND “Please enter age” TO DISPLAY
3. RECEIVE age FROM (INTEGER) KEYBOARD
4. WHILE age < 0 DO
5.         SEND “re-enter data” TO DISPLAY
6.         RECEIVE age FROM (INTEGER) KEYBOARD
7. END WHILE

Note that acceptable does not mean accurate, just sensible.

Higher – Reading Standard Reference Language

I would like to remind you that there is no requirement to write answers using Standard Reference Language (SRL). The SQA can sometimes refer to Standard Reference Language as “Pseudocode”, however, as I have previously explained this is not the case. Pseudocode is an informal design that explains a programs function using English like structure.

Examples

Read in a number representing a temperature in degrees Celsius and write it out as a value in degrees Fahrenheit. If the Celsius value is c, then the Fahrenheit value, f, is calculated as follows: f = ( 9 / 5 ) * c + 32.

RECEIVE c FROM (INTEGER) KEYBOARD 
DECLARE f INITIALLY ( 9.0 / 5.0 ) * c + 32 
SEND f TO DISPLAY

Read in 10 numbers and write out the average of those numbers.

DECLARE total INITIALLY 0 
DECLARE count INITIALLY 0 
WHILE count < 10 DO 
    RECEIVE nextInput FROM (INTEGER) KEYBOARD 
    SET total TO total + nextInput 
    SET count TO count + 1 
END WHILE 
SEND total / 10.0 TO DISPLAY

When reading SRL start at the top, working down each line. Take a note on scrap paper of the values given to variables. In SRL constructs start with their NAME and finish with an END and their name. Subprograms can either be a PROCEDURE or FUNCTION, these are named and have parameters (arguments) in parenthesises, functions will have one or more RETURN statements.

Tips

  • If you are asked for the results of the program then pay attention to the IF statements to make sure that you branch the program correctly. Check the number of repetitions on loops as well.
  • If you are asked to spot an error in the code it will more than likely be a logical error rather than a syntax error.

There is an online Haggis (SRL) checker here, remember you don’t need to write SRL just read it.

National 5 – Testing and documenting solutions (Revision)

Test Data

For an exam out of 100

  • Normal (data within expected range) – 78, 45,67, 85, 44
  • Extreme (data at limits of expected range)– 0, 100
  • Exceptional (data out with expected range) – -89, bob

Errors

  • Syntax – The rules of the programming language have been broken. E.g. a typing mistake Displya rather than Display
  • Execution – using Average = total / 0 would give an execution error.
  • Logic –will only show up when you run the program. Please see below

counter = 0
while counter < 0:
counter = counter + 1

Readability of code

  • Internal commentary – information about what the program does written by the programmer alongside the actual code. #Green in python.
  • Meaningful identifiers – Calling variable names that mean something length or height rather than L or H
  • Indentation starting parts of the code slightly into the middle of the page making it easier to read.

Higher – Data Types and Structures (Revision)

  • String: text (str)
  • Integer: whole numbers (int)
  • Real: decimal numbers (float)
  • Boolean: one of two possible values e.g. True/False
  • 1-D Arrays: two or more values of the same data type stored in the same construct
  • Records: two or more values of different data types stored in the same construct
  • Sequential Files: text files that can be opened, closed, read from, written to, created or deleted; identified by a path and filename which is treated as a STRING e.g. “n:\myfiles\testfile.txt” would identify the file testfile.txt in the folder n:\myfiles.

 

Thank you to C O’Toole & A Madill from Braidhurst High School for allowing me to publish this here.