0% found this document useful (0 votes)
28 views8 pages

Plan 6

Uploaded by

Mostafa Rabie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views8 pages

Plan 6

Uploaded by

Mostafa Rabie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Cambridge IGCSE™

*8472529931*

COMPUTER SCIENCE 0478/22


Paper 2 Algorithms, Programming and Logic

You must answer on the question paper.

No additional materials are needed.

INSTRUCTIONS
● Answer all questions.
● Use a black or dark blue pen. You may use an HB pencil for any diagrams or graphs.
● Write your name, centre number and candidate number in the boxes at the top of the page.
● Write your answer to each question in the space provided.
● Do not use an erasable pen or correction fluid.
● Do not write on any bar codes.
● Calculators must not be used in this paper.

INFORMATION
● The total mark for this paper is
● The number of marks for each question or part question is shown in brackets [ ].
● No marks will be awarded for using brand names of software packages or hardware.

This document has pages 8. Any blank pages are indicated.

[Turn over
1 Consider the logic expression:

X = (A XOR B) AND (NOT B AND C)

(a) Draw a logic circuit for this logic expression. Each logic gate must have a maximum of two
inputs. Do not simplify this logic expression.

B X

[4]

(b) Complete the truth table from the given logic expression.

Working space
A B C X

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

[4]
2 This flowchart represents an algorithm to find the average size of groups of visitors to an attraction.

START

NumberGroups 0
Total 0

INPUT
GroupSize

IS Yes
GroupSize Average DIV(Total, NumberGroups)
= 0?

No OUTPUT
"Average group
NumberGroups NumberGroups + 1 size ", Average

Total Total + GroupSize STOP

Complete the trace table using this data:

7, 10, 2, 8, 3, 9, 0, 6

NumberGroups Total GroupSize Average OUTPUT

[4]
3 A storage unit rental company wants to set up a new database table for the storage units that can
be rented.

The table is called StorageUnits and needs to store these details:

• SizeMetres – size in square metres


• Position – first, second or third floor
• Hoist – whether there is a hoist available for the transfer of items
• PriceMonth – the price in dollars for a month’s rental
• StorageID – the code to identify each storage unit, for example S123

(a) (i) Give the name of the field that would be used for the primary key.

......................................................................................................................................... [1]

(ii) State the reason for choosing this field for the primary key.

...........................................................................................................................................

......................................................................................................................................... [1]

(b) Complete the table to identify the most appropriate data type for these fields in the table
StorageUnits

Field Data type


SizeMetres
Position
Hoist
StorageID
[2]

(c) Complete this structured query language (SQL) statement to display only the storage code,
price and size in square metres of all the storage units where there is a hoist available.

SELECT ....................................................................................................................................

FROM ........................................................................................................................................

WHERE .............................................................. ;
[4]
4 The flowchart represents an algorithm.

START

Result Limit DIV 2 + 1


INPUT
Limit
OUTPUT
Numbers[Result]
Count 1

INPUT
Numbers[Count]
STOP

Count Count + 1

No IS Count >
Limit?

IS Numbers[Count] > No
Yes
Numbers[Count + 1]?
Flag TRUE

Yes

Swap Numbers[Count]
IS Flag = No
TRUE?

Numbers[Count] Numbers[Count + 1]
Yes

Flag False Numbers[Count + 1] Swap


Count 1

Flag True

Yes IS Count > No


Limit – 1?

Count Count + 1

6
(a) Complete the trace table for the input data:

7, 47, 50, 52, 60, 80, 63, 70

Numbers

Limit Count [1] [2] [3] [4] [5] [6] [7] Flag Swap Result OUTPUT

[7]
5 Consider the logic expression:

Z = (R OR NOT T) XOR (NOT S AND T)

(a) Draw a logic circuit for this logic expression.

Each logic gate must have a maximum of two inputs.

Do not simplify this logic expression.

S Z

[5]

(b) Complete the truth table from the given logic expression.

Working space
R S T Z

0 0 0

0 0 1

0 1 0

0 1 1

1 0 0

1 0 1

1 1 0

1 1 1

[4

9
6 A database table called SoftDrinks stores details of the soft drinks sold by a small shop.

Field Example data

Name Cola

Supplier Cambridge Beverages

Container Can
SizeCl 330

NumberInStock 30

ReorderLevel 15
Reordered Yes

a. State whether any of the given fields would be suitable as a primary key and give a
reason for your answer.

...................................................................................................................................................

. ................................................................................................................................................ [1]

b. Complete the structured query language (SQL) statement to return the number of
cans the shop has in stock.

SELECT ....................................................... ( ......................... )

FROM .......................................................

WHERE ....................................................... = .......................... ;


[5]

10

You might also like