# F451 - 3.1.3 Data Structures

## a. Numbers in binary, BCD, octal and hex

Binary

A bit is 0 or 1. 4 bits = one nibble. 8 bits = one byte (two nibbles).

1 of 29

## a. Numbers in Binary Questions

Write the number 90 as a bimary number in a single byte (2)

- 90 = 64 + 16 + 8 + 2 = 01011010

Write the number 90 as a number in octal (2)

- 01011010 = 001 011 010 = 132 in total

Explain the relationship between the binary and octal represetations of the number 90 (2)

- Groups of 3 binary bits (from the right) and Give octal digits when converted into decimal values

Express the decimal number 95 in binary in a single 8-bit byte; in binary codd decimal in a single 8-bit byte; as a hexadecimal number.

- 95 = 64 + 16 + 8 + 4 + 2 + 1 = 01011111

- 95 = 1001 0101 in binary coded decmal  (in this each digit is split up into 4 bits)

- From the first part, 95 = 01011111 = 0101 1111 = 5F

2 of 29

## b. Complements and Sign and Magnitude

We have a number of ways to represent negative binaries, two of which are considered below. In each case we use the most significant bit (left), to represent the minus sign. In what follows we are assuming that we are considering a single byte.

In two complement form a 1 in that position can be thought of as representing the number -128 whereas the rest of the number remains positive. E.g. 10010001 would represent -128 + 16 + 1 = -111.

In sign and magnitude form the most significant bit simply represents + (if its 0) or - (if it is 1). The remainder of the byte is ebaluated normally. For example, the same binary number (10010001) if encoded in sign and magnitude form would represent the number -(15 + 1 = +17) = -17

1010111011 is an unsigned binary integer. State its denary value (1)

- 699 (i.e. 512 _ 128 + 32 + 16 + 8 + 2 + 1)

1010111011 is a binary number in sign and magnitude form. State its denary value (2)

- -187 (because, the most significant bit is a 1 so the number is negative. The remaining bits represent (128 + 32 + 18 + 8 + 2 +1) = 187 so the answer is -187

3 of 29

## b. Data

1010111011 is a binary number in 2's complement form. State its denary value (2)

- -325 (because, the most significant bit is a 1 so the number is negative and since this is in two's complement form is worth -512. The remaining bits represent (128 + 32 + 16 + 8 + 2 +1) = 187 so the final answer is -512 + 187 = -325.

Explain why sign and magnitude form is rarely used for computer arithmetic (3)

- Two types of data in same byte - must be treated differently from the rest of the byte

- Makes the arithmetic algorithms very complex

- Extending from 1 byte to 2 or more bytes very difficult

Write the number -90 as a twos complement binary number in a single byte (1)

- -90 = -128 + 32 + 4 + 2 = 10100110

4 of 29

## b. Data

Write the number -58 as a twos complement binary number in a single byte (1)

- -58 = -128 + 64 + 4 + 2 = 11000110

1 0 1 0 0 1 1 0

1 1 0 0 0 1 1 0 =

0 1 1 0 1 1 0 0

0 1 1 0 1 1 0 0

0 0 0 0 1 1

Explain the result (2)

- Answer is +108 but it should be -148

- The largest magnitude negative number in a byte is -128... so the answer cannot be represented 0

gg0

fccccfffff

5 of 29

## b. Data

Explain the result (2)

Using an 8 bit byte change -60 into a twos complement binary number (2)

Using 8 bit bytes describe how twos complement can be used by a computer can be used by a computer to calculate the answer to 93 - 51 (4)

- 93 turned into 01011101

- 93 - 51 = 93 + (-51)

- (-51)= 11001101

- 1001010

- Ignore carry/00101010

6 of 29

## c. Integer Binary Arithmetic

ALWAYS SHOW WORKING WHEN ASKED THE BELOW TYPE OF QUESTIONS

10110010 and 00100110 are unsigned binary integers. Add together the binary numbers (2)

1  0  1  1  0  0  1  0

0  0  1  0  0  1  1  0

1  1  0  1  1  0  0  0

0  1  0  0  1  1

Carry out the subtraction (2)

1  0  1  1  0  0  1  0

0  0  1  0  0  1  1  0

1  0  0  0  1  1  0  0

(above question needs finishing off (f451 page 37)

7 of 29

## c. Integer Binary Arithmetic

ALWAYS SHOW WORKING WHEN ASKED THE BELOW TYPE OF QUESTIONS

10110010 and 00100110 are unsigned binary integers. Add together the binary numbers (2)

1  0  1  1  0  0  1  0

0  0  1  0  0  1  1  0

1  1  0  1  1  0  0  0

0  1  0  0  1  1

Carry out the subtraction (2)

1  0  1  1  0  0  1  0

0  0  1  0  0  1  1  0

1  0  0  0  1  1  0  0

(above question needs finishing off (f451 page 37)

8 of 29

## c. Integer Binary Arithmetic

ALWAYS SHOW WORKING WHEN ASKED THE BELOW TYPE OF QUESTIONS

10110010 and 00100110 are unsigned binary integers. Add together the binary numbers (2)

1  0  1  1  0  0  1  0

0  0  1  0  0  1  1  0

1  1  0  1  1  0  0  0

0  1  0  0  1  1

Carry out the subtraction (2)

1  0  1  1  0  0  1  0

0  0  1  0  0  1  1  0

1  0  0  0  1  1  0  0

(above question needs finishing off (f451 page 37)

9 of 29

## d. Character Sets

d. Explain the use of code to represent a character set (ASCII, EBCDIC and UNICODE)

CHARACTER SET

The symbols that a computer can recognise and use

Each symbol is distinguishable from all others

E.g. ASCII, UNICODE, EBCDIC

APPLICATIONS THAT NEED CHARACTER SETS OF DIFFERENT SIZES

Word Processing

ATM terminal

- ATM uses 10 digits + 6 command codes, with 4 bits per character

10 of 29

## d. Character Sets (2)

HOW ARE CODES USED TO REPRESENT DIFFERENT CHARACTER SETS?

Each required character is given a unique binary code

The more characters required, the more bits in each code

The number of bits to represent the code establishes the size of a byte

E.g. ASCII uses 8 bits per character - 256 maximum number of characters

EBCDIC uses 8 bits per character - 256 maximum number of characters

UNICODE uses 16 bits per character - 65536 maximum number of characters

Number of characters will therefore tend to be a power of 2

Allows keys to have different characters

11 of 29

## e. Methods of gathering and inputting data

e. Describe manual and automatic methods of gathering and inputting data into a system, including form design, keybaord entry, voice recognition, barcodes, optical mark recognition (OMR), optical character recognition (OCR), magnetic ink character recognition (MICR), touchscreens; image capture, chip and pin, sensors and remote data logging

MANUAL METHOD

- A form would be used to collect the required data

- The form should not be ambiguous

- The data is then input into the computer via a keyboard

- i.e. an operator would read the data in the form and type it into the computer

12 of 29

## e. Methods of gathering and inputting data (2)

AUTOMATIC METHODS

Voice recognition

- Use of a microphone to read instructions into a computer

- Data is input in audio form directly through use of a microphone

- Sound waves produced are sampled and digitalised

- Digital values compared with stored values in a library of sounds

- Digital values interpreted by computer

- Command is executed if understoof

- e.g. security systems/mobile telephones

13 of 29

## e. Methods of gathering and inputting data (3)

Barcodes
How a barcode stores data

A barcode comprises of patterns of light/dark lines of varying widths

Pairs of lines store digits

Check digit included in barcode for automatic checking

Start and stop codes allows bars to be read both ways

How data is input from barcodes

A laser, infrared scanner is used

Reflections show up thickness of lines

Check digit calculation done for immediate checking of reading

Start and stop codes decide direction of reading

14 of 29

15 of 29

## e. Methods of gathering and inputting data (4)

Barcodes continued...

High level of accuracy achieved

Data capture is fast and eliminates human entry

Barcodes can be easily misread by the system and barcodes are easily damaged

Optical Character Recognition (OCR)

Shapes of individual characters are scanned optically

These shapes are compared with standard shapes stored in the computer's memory

Unreliable form of input - only effective when having to recognise a standard (printed) character set rather than handwriting

E.g. reading documents for the blind, scanning a hard copy into a word-processing

16 of 29

## e. Methods of gathering and inputting data (5)

Magnetic Ink Character Recognition (MICR)

Special characters are printed on documents in magnetisable ink

Are both computer and human readable

Magnetised ink means that characters are more likely to be read accurately

E.g. account numbers on cheques

Optical Mark Recognition (OMR)

Position of makrs on a document equates with information

Document is scanned for coordinates of marks

Scanner reads the reflected light from marks

E.g. input of lottery choices

17 of 29

## e. Methods of gathering and inputting data (6)

Multiple choice tests

Correct responses will all be in predetermined positions

There are no areas for debate

Tests are marked very quickly and very accurately

Position of shaded areas compared with 'correct' positions

Number of correct positions added and stored in a file according to candidate number

Touch screens

Input achieved by pressing on the screen

Used when there are a finite number of possible choices

User restricted to what available on the screen, e.g. ATM machines

18 of 29

## e. Methods of gathering and inputting data (7)

Image Capture

Taking and storing pictures

Scanner

- To input pictures from hard copy

- Pixels are scanned and reflected is measured

Electronic camera

- Camera would take a picture

- Lens focuses image onto matrix of receptors

- Picture transferred to computer via cable orr a memory card

19 of 29

## e. Methods of gathering and inputting data (8)

Chip and pin

Personal information is extremly sensitive and valuable

Stored on a computer chip embedded into a card

E.g. credit or debit card - to input card details

SENSORS

Input device that detects physical quantities

Including heat, light, sound, movement

Sensors convert these quantities into electrical signals

E.g. measurig temperature, measuring humidity

20 of 29

## e. Methods of gathering and inputting data (9)

Magnetic Stripe Card

Data can be read from the *****e by a magnetic *****e reader

Encoded informaiton stored on the ***** an be automatically read into a computer

Very accurate/input not prone to human errors

Stripe can only store a small amount of information

E.g. credit card/debit card/membership card

21 of 29

## f. Validation and Verification

f. Explain the techniques of validaiton and verification, and describe validation tests which can be carried out on data

VERIFICATION

Inputs data/value twice to the computer system

System checks the two inputs are the same

Another technician also enters data/values to the computer system

System checks two inputs are the same

VALIDATION

A check on data input to the system by comparing the data input with a set of rules that the computer has been told the data must follow

RANGE CHECK
- Check to see if the value entered is in a certain range

22 of 29

## f. Validation and Verification (2)

Validation continued...

CHARACTER CHECK/TYPE CHECK

- Checks to see if entered data is of the correct type

E.g. letters of alphabet the name

LENGTH CHECK

- Checks  to see if input data contains a certain number of characters

- Number of characters entered should be within a pre-defined limit

FORMAT CHECK

- E.g. Herd type should be 1 character followed by 3 digits

PRESENCE CHECK

- Ensure that a value has actually been entered

23 of 29

## f. Validation and Verification (3)

EXISTENCE CHECK

- Input data is searched on a database. If data is not recognised then either the data does not exist on the database or the data has been wrongly read

CHECK DIGIT

- In a string of digits, one of the numbers is special. It is called the check digit. The value of this digit is calculated by applying a simple algorithm to the other digits. When the strings of digits are sent, the check digit is calculated again at the receiving end. if the arithmetic does not give the check digit, then the string of digits have been corrupted during data transmission

24 of 29

## g. Forms of Output

g. Describe possible forms of output such as graphs, reports, interactive presentations, sound, video, images, animations, stating the advantages and disadvantages of each with reference to the target audience.

GRAPHS

- Shows trends very clearly when two variables need to be compared

- Not possible to take reliable readings to any degree of accuracy

REPORTS

Hard copy printout of values for future reference/research

- Produces the actual figures specified by the user

- May need skill to interpret significance of the figures themselves

- E.g. to allow analysis of a patient condition in a hospital

25 of 29

## g. Forms of Output (2)

Forms of output continued...

VIDEO

- Takes large amounts of memory to produce

- Useful for demonstrations for technique

IMAGES/GRAPHICS

- Used to enhance understanding - shows details

- Makes trend spotting easier

- Created using graphical packages and scanned into a computer or imported from camera

SOUND

- Beep to signify data has been accepted

- To present alarm signals

26 of 29

## g. Forms of Output (2)

Forms of output continued...

VIDEO

- Takes large amounts of memory to produce

- Useful for demonstrations for technique

IMAGES/GRAPHICS

- Used to enhance understanding - shows details

- Makes trend spotting easier

- Created using graphical packages and scanned into a computer or imported from camera

SOUND

- Beep to signify data has been accepted

- To present alarm signals

27 of 29

## h. Backup and Archiving

h. Explain the procedure involved in backip up data and archiving, including the difference between data that is backed up and data that is archived

BACKING UP DATA

Making copies of important files

Storing them on a portable medium

Copies are kept away from the originals (master files)

So that if the original files are corrupted, they can easily be replaced

REASON - files are important to an organisation and so must be protected

Data could become corrupted and data could be lost

28 of 29

## h. Backup and Archiving (2)

ARCHIVING

Storing the data produced on a long term storage device - So it can be referred to if necessary. REASON - Data is available without taking up space on working storage

BACKING UP ROUTINE

FREQUENCY OF BACKUP - e.g. backup copy taken weekly

ON OR OFFLINE - e.g. at least one copy should be stored offline

MULTIPLE COPIES of data should be taken

INCREMENTAL OR FULL BACKUPS - preferably incremental backups taken

WHEN TAKEN? immediately after updating of data on computer system

WHERE STORED? backups should be stored in more than 1 location and stored in secure locations

MEDIA? copies of all files stored onto a removable storage device, e.g. CD-RW

29 of 29