Name: Class Teacher: Date: OCR H446 A-Level Computer Science REVISION BOOKLET 1.4 DATA TYPES, DATA STRUCTURES AND ALGORITHMS Content in H446 A-Level Computer Science: 1.1 The characteristics of contemporary processors, input, output and storage devices 1.2 Software and software development 1.3 Exchanging data 1.4 Data types, data structures and algorithms 1.5 Legal, moral, cultural and ethical issues 2.1 Elements of computational thinking 2.2 Problem solving and programming 2.3 Algorithms www.learn-computerscience.com
1.4.1 DATA TYPES TOPIC Primitive data types, integer, real/floating point, character, string and Boolean Represent positive integers in binary Use of sign and magnitude and two s complement to represent negative numbers in binary Addition and subtraction of binary integers Represent positive integers in hexadecimal Convert positive integers between binary, hexadecimal and denary Representation and normalisation of floating point numbers in binary Floating point arithmetic, positive and negative numbers, addition and subtraction Bitwise manipulation and masks: Shifts Combining with AND, OR and XOR How character sets (ASCII and UNICODE) are used to represent text
1.4.1 DATA TYPES PRIMITIVE DATA TYPES INTEGER REAL/FLOATING POINT CHARACTER STRING BOOLEAN REPRESENT POSITIVE INTEGERS IN BINARY NEGATIVE NUMBERS IN BINARY SIGN AND MAGNITUDE TWO S COMPLEMENT
ADDITION OF BINARY INTEGERS SUBTRACTION OF BINARY INTEGERS REPRESENT POSITIVE INTEGERS IN HEXADECIMAL CONVERT POSITIVE INTEGERS BETWEEN BINARY, HEXADECIMAL AND DENARY BINARY HEXADECIMAL DENARY REPRESENTATION AND NORMALISATION OF FLOATING POINT NUMBERS IN BINARY
FLOATING POINT ARITHMETIC POSITIVE AND NEGATIVE NUMBERS ADDITION AND SUBTRACTION BITWISE MANIPULATION AND MASKS SHIFTS COMBINING WITH AND, OR, XOR HOW CHARACTER SETS (ASCII AND UNICODE) ARE USED TO REPRESENT TEXT
1.4.2 DATA STRUCTURES TOPIC Arrays (of up to 3 dimensions) Records Lists Tuples The following structures to store data: Linked-list Graph (directed and undirected) Stack Queue Tree Binary search tree Hash table How to create, traverse, add data to and remove data from the data structures mentioned above
ARRAYS (OF UP TO 3 DIMENSIONS) 1.4.2 DATA STRUCTURES RECORDS LISTS TUPLES THE FOLLOWING STRUCTURES TO STORE DATA LINKED-LIST GRAPH (DIRECTED AND UNDIRECTED) STACK
QUEUE TREE BINARY SEARCH TREE HASH TABLE HOW TO CREATE, TRAVERSE, ADD DATA AND REMOVE DATA FROM DATA STRUCTURES
1.4.3 NETWORKS TOPIC Define problems using Boolean logic Manipulate Boolean expressions, including the use of Karnaugh maps to simplify Boolean expressions Use of the following rules to derive or simplify statements in Boolean algebra: De Morgan s Laws Distribution Association Commutation Double negation Using logic gate diagrams and truth tables The logic associated with D type flip flops, half and full adders
DEFINE PROBLEMS USING BINARY LOGIC 1.4.3 NETWORKS MANIPULATE BOOLEAN EXPRESSIONS INCLUDING USE OF KARNAUGH MAPS TO SIMPLIFY BOOLEAN EXPRESSIONS DERIVE OR SIMPLIFY STATEMENTS IN BOOLEAN ALGEBRA DE MORGAN S LAWS DISTRIBUTION ASSOCIATION COMMUTATION
DOUBLE NEGATION USING LOGIC GATE DIAGRAMS AND TRUTH TABLES THE LOGIC ASSOCIATED WITH D-TYPE FLIP FLOPS, HALF AND FULL ADDERS
EXAM QUESTIONS QUESTION 1 A supermarket uses a stock control system. Details of products are stored on a stock database. The quantity of a particular product in stock is stored as a binary number using two bytes. There are 312 tins of beans left in stock. How would this quantity be represented as a binary number in the computer? [2] The name of a product is stored using characters from the computer s character set. Explain what is meant by the character set of a computer. [2] Explain how codes are used to represent a character set. [3]
QUESTION 2 Laser Tag is a game where teams of players move round an arena shooting each other with infrared guns. Players wear sensors that keep track of how many times they have been hit by the laser. This is known as being tagged. At the end of each match, players upload their score to a computer. The computer stores the scores in the order they are received in a 2D array called player. The array stores the team as an integer (1 for green, 2 for red) and their score. An extract of the array called player is shown below. The first entry shows a green team member scored 45 points and the next shows a red team member scored 30 points. 1 45 2 30 2 46 1 31 1 10 1 32 2 2 Once all the players have uploaded their scores, the computer adds up the scores for each team. Using pseudo code, write a program for a procedural language that works out and outputs the total score for each time. You may assume that there are always 20 players. [6]
QUESTION 3 Convert the unsigned binary number 11110000 to: Denary Hexadecimal An AND operation with the mask 10101010 is applied to the binary number 01010101. Show the result. An OR operation with the mask 10101010 is applied to the binary number 01010101. Show the result.
00001100 is shifted two places to the left. Show the result. Identify what arithmetic operation this shift is equivalent to. Convert the denary number -8 to: An 8-bit sign and magnitude binary number. An 8-bit two s complement binary number.
A computer represents floating point binary numbers using a 6-bit mantissa and a 4-bit exponent, both using two s complement. Add the following three numbers together and give the answer in the format described. You must show your working. [6]
QUESTION 4 An XOR gate is shown below. Complete the truth table for XOR. A B Q 1 1 1 0 0 1 0 0 [2] A set of logic gates are connected as below.
Complete the Truth Table below. A B Cin S Cout 1 1 1 1 1 0 1 0 1 1 0 0 0 1 1 0 1 0 0 0 1 0 0 0 [4] Explain what the circuit does. You should refer to A, B, Cin, S and Cout in your answer. [4]
Write a Boolean expression equivalent to S. Write a Boolean expression equivalent to Cout. [2]
QUESTION 5 Data structures may be described as static or dynamic. State the meaning of the term static. State one type of data structure that is always considered to be static. State the meaning of the term dynamic. Give one disadvantage of using a dynamic data structure.
QUESTION 6 A binary search tree is used to store the names of dog breeds. The breeds Doberman and Dalmatian are added to the tree in that order. Add them to the diagram below. Explain how you would determine if the breed Pug is in the binary search tree. [3] Explain how you would determine if the breed Spaniel is in the binary search tree. [3]
The tree is coded using object-oriented programming. Each dog breed is represented by an object of class Node. The Node class has the methods: getleftnode() returns the left hand child node or null if there is no left hand child. getrightnode() returns the right hand child node or null if there is no right hand child. getbreed() returns the name of the breed stored in that node. The program allows for a breed name to be entered, and depending on whether the breed is in the tree or not, displays either: Complete the program below. Credit will be given for readability of code. [6]