Well, time flies and here comes another Semester Exam of Computer Science for this badge.

The questions were really simple and I think it would be good for the students to practice their logic and algorithmic thinking.

Here are some of the questions:

Define virtual memory and give an example of when it might be used. (2 marks)
Virtual memory is a memory created from the storage, usually hard drive, so it’s not a physical memory that we used to know. We use this kind of memory when our computers has too many processes and it has lack of memory, so we can create a virtual memory to solve this issue.

Explain one reason why flash memory is increasingly being used as a portable storage medium. (3 marks)
The benefit why flash memory has become popular is because it’s small, easy to carry and portable, so the manufacturer tends to create this kind of memory to have a larger storage. Comparing with external hard drive, a flash memory can even be put in our pocket .

Define data integrity and identify one factor that affects integrity when data is transmitted from one computer to another . (2 marks)
The ability of the data to remain the same and not to be changed by accidentally, technical issues or by a hacker. One factor that the integrity may fail is the media that used to transfer the data is broken, so the data may be corrupt in copying, thus may led to the lack of data integrity.

Trace the following algorithmic extract for an input of 34.  (2 marks)
input (i);
k = i mod 6;
m = i div 6;
output (m*6+k);
Result:
k = 34 mod 6 -> 4
m = 34 div 6 -> 5
output = (5 * 6) + 4 -> 34

Hamming code consists of 7 bit (binary digit) that used to check error. 7 bit consist of 4 digit BCD (Binary Coded Decimal) and 3 parity bit!    For Odd Parity, check the following bit using Hamming Code to determine an error bit! (4 marks)
(a) 1010000
(b) 1110011
(c) 1101011
(d) 1011110
To solve Hamming Code problems, we need to know about the table of the parity P4 P2 P1which formed as a binary
a. P1 = 1 1 0 0 (F) P2 = 0 1 0 0 (E) P4 = 0 0 0 0 (F)  FEF -> bit 5
b. P1 = 1 1 0 1 (E) P2 = 1 1 1 1 (F) P4 = 0 0 1 1 (F)  FFE -> bit 6
c. P1 = 1 0 0 1 (F) P2 = 1 0 1 1 (E) P4 = 1 0 1 1 (E)  EEF -> bit 1
d. P1 = 1 1 1 0 (E) P2 = 0 1 1 0 (F) P4 = 1 1 1 0 (E)  EFE -> bit 2

Now the flowchart question;

Examine the flowchart next to this question. Please note that COUNTS is a two dimensional array that hold an INTEGER value that refers to total of product that need to be counted every hour.
Example:

COUNTS[0][0] = 5
COUNTS[0][1] = 10

etc.

(a) Construct Pseudo Code (refers to the Approved Notation from IB) from the FlowChart! (3 marks)
(b) Outline the output! (1 mark)
(c) State the purpose of the algorithm!(1 mark)
(d) Construct a function that can return sum of the total product for the whole week! (4 marks)

flowchart

a. The Pseudo Code has the rules, students please refers to the document Approved Notation for Developing Pseudo Code from IB!
DAY = 0
HOUR = 0
SUM = 0
loop while DAY <> 7
if HOUR = 24 then
output DAY, SUM
HOUR = 0
SUM = 0
DAY = DAY + 1
else
SUM = SUM + COUNTS[DAY][HOUR]
HOUR = HOUR + 1
end if
end loop
b. The output will print the number of day, together with the total product per day, so it will like this:
1,100 2,150 … 7,100
We can’t measure the SUM, because we don’t know the INTEGER value that stored in each array
c. The purpose of the algorithm is to sum total of the production in daily basis, which has stored in two dimensional arrays represent for DAY and HOUR
d.
public int total_per_week ()
{
int day = 0;
int hour = 0;
int sum = 0;
int total = 0;
while (day!=7)
{
if (hour==24)
{
total=total+sum;
hour =0;
sum=0;
day=day+1;
}
else
{
sum=sum+counts[day][hour];
hour=hour+1;
}
}
return total;
}

Consider the simplified logic circuit shown below. It has three inputs (X, Y and Z) and one output (OUT).
The output at OUT is the same as the input signal at X when the input signal at Z is 0.
The output at OUT is the same as the input signal at Y when the input signal at Z is 1.
(a) Construct a truth table that summarizes this behavior. (3 marks)
(b)
(i) From the truth table, construct the Boolean expression for output OUT in terms of inputs X, Y and Z. (2 marks)
(ii) Show that the expression can be simplified to YZ + XZ’. (2 marks)
(c) Draw the logic circuit corresponding to the expression YZ + XZ’. (3 marks)

a.
X Y Z   Output
0 0 0    0
0 0 1     0
0 1 0     0
0 1 1      1
1 0 0     1
1 0 1     0
1 1 0     1
1 1 1      1
b.
F = X’YZ + XY’Z’ + XYZ’ + XYZ
= YZ(X+X’) + XZ'(Y+Y’)
= YZ + XZ’
c. clear

8.
(a)
(i) Define the term recursion. (1 mark)
(ii) Describe one advantage and one disadvantage of recursion. (4 marks)
Examine the following recursive method.
public int mystery(int x, int y)
{
if (x < y)
{ return 0; }
else
{ return 1 + mystery(x – y, y); }
}
(b) State the value of variable w after
(i) int w = mystery(2, 3) ; (1 mark)
(ii) int w = mystery(2, 2) ; (1 mark)
(iii) int w = mystery(7, 3) . (1 mark)
(c) Assuming that both arguments are positive, determine the purpose of the method mystery. (2 marks)

Recursion is a procedural process that call or execute procedure within the same procedure until one condition has reached
The advantage: the program’s structure seems to be more simple
The disadvantage: the analyzing of the program could be more complicated and it consumes more memory to execute recursive
b.i 0  ii.0  iii.2
c.the function will return the result of the division from its parameter

(a) Convert the decimal number 212 into binary. (2 marks) 11010100
(b) Convert the binary number 1110 1011 into hexadecimal. (1 mark) EB

Two arrays, student[] and grade[], are shown below.

student[]

Pietro, Michelle, Archie, Sol Me, Dyna, Clara

grade[]

7 4 5 2 5 9

The following method, deleteStudent(), is used to manipulate the two arrays.
It contains an error. It can be assumed that the student name entered into the method is present in the array.

public void deleteStudent(String name)
{
int j = 0;
for (int c = 0; c < 6; c++)
{
if (student[c] == name)
{ j = c; }
}
for (int c = j; c < 6; c++)
{
student[c] = student[c + 1];
grade[c] = grade[c + 1];
}
}

(a) Copy and complete the table below for the first loop in the call
deleteStudent(“Archie”). (4 marks)

(b)
(i) Identify the error. (1 mark)
(ii) State the type of error. (1 mark)
(c) Outline one way in which the method could be adapted to avoid the error. (2 marks)
(d) Suggest one way in which the efficiency of the method could be improved. (2 marks)

b. error has occurred in the second loop which it will swap all the elements even though the name was not the same.
This is a logical error – an error type which produce a result that is not correct
c. we can easily avoid this error by put the second loop on else statement
d. we can put a flag variable in first loop, so if the name they search is in the first element of array, the variable will set to exit from the loop immediately, which means the loop will not execute for the rest of the elements of array

A bus company that provides services within a city has decided to equip all its routes with ‘intelligent’ bus-stops. These bus stops will include a continually-updated visual display giving limited information regarding the arrival of the buses for each of the routes that use each stop.

(a) State two items, relating to the arrival of a particular bus, which might be displayed. (2 marks)

Whenever a bus passes a bus-stop, it automatically sends data to the central computer regarding its
current location. The computer immediately processes this information and then sends appropriate
data out to the bus-stops on the same route.

(b) State which type of processing is taking place. [1 mark]

All processing is carried out at the company’s central computer, where 2-D arrays are used to store
the times (in minutes) between bus-stops for each route.

For example, for Route A, the following array, timesA[][] contains data.

e.g. timesA[2][4] stores the number of minutes that a bus would take travelling from bus-stop # 2 to bus-stop # 4. From the above table this would be 5 minutes.

(c)
(i) Identify, from the table, the number of minutes to travel from bus-stop # 0 to bus-stop # 4. (1 mark)
(ii) Explain the use of the data -1 in the table. (2 marks)
(d) Explain why this system should be tested thoroughly before being put into operation. (3 marks)

The system is first tested using one bus on Route A. Whenever the central computer receives data from the bus on Route A the method findTimes() is called. This method receives the current location of the bus (currentStop) and the array timesA, and then sends out the number of minutes until arrival to each bus-stop that has not yet been passed by the bus.

(e) Construct the method findTimes(). It can be assumed that a method sendTimes() exists, which sends the time in minutes to a particular bus-stop. (6 marks)

(f) Explain how the system could be improved so as to give more accurate data regarding the arrival of the buses (2 marks)

(g) Suggest, with reasons, one other way in which the system could be expanded to be of benefit to their customers. (3 marks)

Tags: ,