Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In a particular computer system, real numbers are stored using floating-point representation with: 12 bits for the mantissa 4 bits for the exponent two's complement


In a particular computer system, real numbers are stored using floating-point representation with: 12 bits for the mantissa 4 bits for the exponent two's complement form for both mantissa and exponent.

(a) Calculate the normalised floating-point representation of +4.5 in this system. Show your working. Mantissa Exponent Working


(b) Calculate the normalised floating-point representation of 4.5 in this system. Show your working. Mantissa Exponent Working .


(c) Calculate the denary value for the following binary floating-point number. Show your working. Mantissa Exponent 0 0 0 1 1 0 0 0 0 0 0 0 0 1 0 1 Working


(d) (i) State whether the floating-point number given in part (c) is normalised or not normalised.


(ii) Justify your answer given in part (d)(i).


(e) The system changes so that it now allocates eight bits to both the mantissa and the exponent. Explain two effects this has on the numbers that can be represented.


2.The TCP/IP protocol suite can be viewed as a stack with four layers. (a) Complete the stack by inserting the names of the three missing layers. Application layer

[3] (b) Bit Torrent is a protocol used at the Application layer for the exchange of data.

(i) State the network model used with this protocol. ..(iii) Explain how applications use Bit Torrent to exchange data.


(c) State two other protocols that are used at the Application layer for the exchange of data. For each protocol, give a different example of an appropriate exchange of data.


Question 2;

A student writes a program in a high-level programming language. A compiler translates the program into machine code. (a) The compilation process has a number of stages. The output of the lexical analysis stage forms the input to the next stage.

(i) Identify this stage.

(ii) State two tasks that occur at this stage.


(b) The program uses pseudocode in place of a high-level language. There are a number of reasons for performing optimisation. One reason is to produce code that minimises the amount of memory used. State another reason for the optimisation of code.


(c) The following statement assigns an expression to the variable A. Suggest what a compiler could do to optimise the following expression. A B + 2 * 6


(d) These lines of code are to be compiled: X A + B Y A + B + C Following the syntax analysis stage, object code is generated. The equivalent code, in assembly language, is shown below: 01 LDD 436 // loads value A 02 ADD 437 // adds value B 03 STO 612 // stores result in X 04 LDD 436 // loads value A 05 ADD 437 // adds value B 06 ADD 438 // adds value C 07 STO 613 // stores result in Y Suggest what a compiler could do to optimise this code.


Question 3;

Ed wants to send a message securely. Before sending the message, the software encrypts it using a symmetric key. (a) (i) Describe what is meant by symmetric key encryption.


(ii) State two drawbacks of using symmetric key encryption.


(b) The symmetric key is to be exchanged before the message is sent. To exchange the key securely, the use of quantum cryptography is being considered. State two possible benefits of using quantum cryptography



Question 4:

7 An ordered binary tree Abstract Data Type (ADT) has these associated operations: create tree add new item to tree traverse tree A student is designing a program that will implement a binary tree ADT as a linked list of ten nodes. Each node consists of data, a left pointer and a right pointer. A program is to be written to implement the tree ADT. The variables and procedures to be used are listed below: Identifier Data type Description Node RECORD Data structure to store node data and associated pointers. LeftPointer INTEGER Stores index of start of left subtree. RightPointer INTEGER Stores index of start of right subtree. Data STRING Data item stored in node. Tree ARRAY Array to store nodes. NewDataItem STRING Stores data to be added. FreePointer INTEGER Stores index of start of free list. RootPointer INTEGER Stores index of root node. NewNodePointer INTEGER Stores index of node to be added. CreateTree() Procedure initialises the root pointer and free pointer and links all nodes together into the free list. AddToTree() Procedure to add a new data item in the correct position in the binary tree. FindInsertionPoint() Procedure that finds the node where a new node is to be added. Procedure takes the parameter NewDataItem and returns two parameters: Index, whose value is the index of the node where the new node is to be added Direction, whose value is the direction of the pointer ("Left" or "Right").


These pseudocode declarations and this procedure can be used to create an empty tree with ten nodes. TYPE Node DECLARE LeftPointer : INTEGER DECLARE RightPointer: INTEGER DECLARE Data : STRING ENDTYPE DECLARE Tree : ARRAY[0 : 9] OF Node DECLARE FreePointer : INTEGER DECLARE RootPointer : INTEGER PROCEDURE CreateTree() DECLARE Index : INTEGER RootPointer -1 FreePointer 0 FOR Index 0 TO 9 // link nodes Tree[Index].LeftPointer Index + 1 Tree[Index].RightPointer -1 NEXT Tree[9].LeftPointer -1 ENDPROCEDURE


(a) Complete the pseudocode to add a data item to the tree. PROCEDURE AddToTree(BYVALUE NewDataItem : STRING) // if no free node report an error IF FreePointer ............................................................................................................ THEN OUTPUT "No free space left" ELSE // add new data item to first node in the free list NewNodePointer FreePointer ............................................................................................................................. // adjust free pointer FreePointer .............................................................................................. // clear left pointer Tree[NewNodePointer].LeftPointer ................................................ // is tree currently empty? IF ...................................................................................................................... THEN // make new node the root node .............................................................................................................. ELSE // find position where new node is to be added Index RootPointer CALL FindInsertionPoint(NewDataItem, Index, Direction) IF Direction = "Left" THEN // add new node on left ........................................................................................... ELSE // add new node on right ........................................................................................... ENDIF ENDIF ENDIF ENDPROCEDURE


(b) The traverse tree operation outputs the data items in alphabetical order. This can be written as a recursive solution. Complete the pseudocode for the recursive procedure TraverseTree. PROCEDURE TraverseTree(BYVALUE Pointer : INTEGER)


Question 5:

A company keeps details of its product items in a 1D array, Stock. The array consists of 1000 elements of type StockItem. The record fields of StockItem are: Field Typical value ProductCode "BGR24-C" Price 102.76 NumberInStock 15

(a) Write pseudocode to declare the record structure StockItem.


(b) Write pseudocode to declare the Stock array


(c) Write pseudocode to modify the values to element 20 as follows: set the price to 105.99 increase the number in stock by 12


(d) A stock report program is developed. Write pseudocode to output the information for each stock item that has a price of at least 100. Output the information as follows: Product Code: BGR24-C Number in Stock: 15


Question 6:

Members of a family use the same laptop computer. Each family member has their own password. To be valid, a password must comply with the following rules: 1 At least two lower-case alphabetic characters 2 At least two upper-case alphabetic characters 3 At least three numeric characters 4 Alphanumeric characters only A function, ValidatePassword, is needed to check that a given password follows these rules. This function takes a string, Pass, as a parameter and returns a boolean value: TRUE if it is a valid password FALSE otherwise (a) Write pseudocode to implement the function ValidatePassword. Refer to the Insert for the list of pseudocode functions and operators.


(b) The ValidatePassword function will be tested. (i) Give a valid password that can be used to check that the function returns TRUE under the correct conditions. Password1: .................................................................................................................. [1] (ii) Password1 is modified to test each rule separately. Give four modified passwords and justify your choice.


(iii) When testing the ValidatePassword function it is necessary to test all possible paths through the code. State the name given to this type of validation testing.

(iv) A program consisting of several functions can be tested using a process known as 'stub testing'. Explain this process.


Question 7;

LogArray is a 1D array containing 500 elements of type STRING. A procedure, LogEvents, is required to add data from the array to the end of the existing text file LoginFile.txt Unused array elements are assigned the value "Empty". These can occur anywhere in the array and should not be added to the file. Write pseudocode for the procedure LogEvents. Refer to the Insert for the list of pseudocode functions and operators.




Step by Step Solution

3.48 Rating (151 Votes )

There are 3 Steps involved in it

Step: 1

Lets tackle these questions step by step Question 1 a To represent 45 in normalized floatingpoint representation Given Sign bit 0 for positive Exponent 45 1001 binary 1001 22 So the exponent is 2 whic... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Cambridge International AS & A Level Computer Science

Authors: David Watson, Helen Williams

1st Edition

1510457593, 978-1510457591

More Books

Students also viewed these Programming questions