Wednesday, February 9, 2011

Answers 1.3


1.      A roll of wallpaper is 50cm wide. Each roll is 15m long. A room measures x metres long by y metres wide and 2.5 metres high. Ignoring the door and any windows that there may be, describe an algorithm for calculating the number of rolls of wallpaper needed to paper the room.                                                                 (4)

   A.  -Add twice x to twice y/Work out total length of walls
         -Divide by .5metres/work out the number of strips of paper needed
         -Divide 15metres by 2.5metres/work out the number of strips in one roll of paper
         -Divide number of strips needed by the number of strips in one roll
         -Indication of the order required.
        
Note that the mark scheme is not presented in any particular algorithmic form. This is because the syllabus does not specify that a particular form be used so it is entirely up to the candidate, provided that the two points about stating the tasks to be carried out and specifying an order are met. Also notice that the first three steps of the algorithm are presented in two ways. One could be called mathematical while the other is descriptive. Either is perfectly acceptable. One last point about the mark scheme is that an algorithm implies that order is important, so it is highly likely that in an exam, such a question would insist on an order as an essential feature of the solution. In other words one mark would be reserved for providing a definite statement of order.
        
 Note also that if the question was changed slightly so that it was a machine in the shop which would calculate the number of rolls of wallpaper for you, then the algorithm would need to have an input of the lengths of the walls, an output of the number of rolls needed, and would also need to go back to the start after producing the output so that the next customer could type in their details. This would mean: 1 mark for input of two values, 1 mark for an output, 1 mark for order (input before output), and 3 marks for a sensible loop with a correct condition statement. That makes 6 marks before doing any of the calculation.

 2.

       Describe the effect of this algorithm.                                                    (4)

   A.  -An unknown number of numbers…
         -is read into the algorithm.
         -When there are no more numbers to read
         -The average (mean) is worked out
         -The answer is then output.
          
Producing an algorithm to anything other than a trivial problem under exam conditions is difficult. One solution to this problem is for the examiner to produce the algorithm for the candidate and then expect the candidate to follow the logic. The example here is a very simple one but illustrates two points. First, the fact that whatever the algorithm is it will be short, and secondly that while many algorithms are mathematically based the mathematics is not necessary to attain full marks. When answering a question like this pay particular attention to the number of marks available, and be careful not to simply write down what is given in the algorithm. E.g. no marks would be given here for saying that one is added to the counter.

3.      Give three advantages to using a top down approach when designing a solution to a problem.                 
                                                                               (3)
   A.  -Many people can be involved in the solution
         -Individual skills can be used
         -A module can be used from the software library
         -Each module is far easier to understand than the whole program is.
         -Fewer errors are likely to be made
         -Any errors that are made will be easier to correct.
          
A standard question, whose answer jumps from the notes.

4.      A piece of software is to be written which will control a central heating system. It is decided that the software is to be written as a set of four modules. State four modules, whose combined solution would be a solution for the whole problem.

   A.  -Handling of the input from the sensors
         -Interface with the owner of the system allowing input of important values
         -Processing module which makes decisions about the heating requirements
         -Control of the output devices in order to carry out the processing decisions
         -Alarm system in case of errors occurring.

5.         X = 1
            WHILE X < 9 DO
                        X = X + 1
                        Y = X * X
                        PRINT Y
            ENDWHILE
         The intention of this module is to print out the square numbers from 1 to 100.
   a)   Write down the output that the module will produce.                          (2)

   A.  -- 4,9,16,25,36,49,64,81
- An indication that the candidate realises that the first value of X that is used is 2 instead of 1
- An indication that the last value used is 9 when it should have been 10.

Notice that the arithmetic is not being tested here. It is possible to get full marks even if you can’t multiply. The examiner is not trying to test your mental arithmetic but is seeing whether you can follow a small section of logic.

  b)    Using the same structure, produce a similar module that will work.     (2)

   A.  - Change the X = 1 to X = 0
         - Change the WHILE X<9 DO to WHILE X<10 DO
        
These are not unique possibilities. There are plenty of other ways of achieving the same results. The mark scheme is really one mark for correcting each of the output errors in the original.

6.         REPEAT
                        INPUT NUMBER
                        IF NUMBER <> 0 THEN TOTAL = TOTAL + NUMBER
                                                                          COUNT = COUNT + 1
                                                             ELSE  ZERO = ZERO + 1
            UNTIL COUNT = 5
            ANSWER = TOTAL/COUNT
            PRINT ANSWER, ZERO
   a)   If the numbers 3,5,4,0,4,0,9,1 are used as data for this procedure, state what the printout will be when the procedure is completed.                         (2)

   A.  5 and 2. (1 mark each)

   b)   Identify the condition statement, and explain what it does.                 (3)

   A.  -IF…THEN…
                   ELSE…
         -Decides whether the number input is zero or not.
         -A count is kept of all the zeros input, and the other numbers are used in the calculation.
         
 Note that the algorithm is provided. It would be hard to expect candidates to produce algorithms of this type in an exam, to all but the most trivial of problems. The description in part (b) can be in the broadest terms. The examiner is not looking for a brilliant insight into the logic, simply for an indication that the student understands the general principles.

7.      State what is meant by the terms
         (i) Source code
         (ii) Object code
         (iii) Machine code                                                                                  (4)

   A.  -Generally, code means a set of instructions designed to carry out a task
         -Source code is the version of the program written by the programmer…
- in high level language.
         -Object code is the executable form of the program…
         -created by the translator
         -Machine code is in binary form.
          
Note that there are plenty of marks available here, and the fact that the mark comes at the end of the question implies that the dotties are lumped together and that the marks are largely interchangeable.
         Teacher’s note: there is no distinction between interpreter and compiler as yet. Even to the extent that students are not penalised for not knowing that the interpreter does not produce an object code. It is not yet in the syllabus, so should not be expected.

8.      Describe the relationship between the source code and the object code.
                                                                                                                        (2)

   A.  -The source code is the original program while the object code is after translation.
         - There is a one to many relationship between the two.
          
Note. This could have been a very complex answer. However, you don’t know a lot about translators and their effects yet, and a look at the number of marks available tells you that the answer is strictly limited. The second mark point is rather strangely put, it simply means that the object code is longer than the source code, and if that’s what you said you would get the mark.

9.      State three types of program error and give an example of each.         (6)

         -Syntax error
         -Mistyping a reserved word, eg typing plint instead of print
         -Logic error
         -A jump instruction that tells the computer to jump to the wrong place
         -Arithmetic error
         -Inappropriate use of arithmetic. Eg dividing by zero
          
Note. There are many possible errors that could be given as examples of each of these. It is sensible to stick to the standard answers that way there is no chance of picking a wrong one.

10.    A program is written that will allow the user to input a list of 5 numbers and will print out the largest and the smallest of them.
         The program is to be tested to see that it works under all conditions. The programmer decides to use the test data 3,4,2,5,6,7 in order to test what will happen if more than 5 numbers are input.
         Give four other different sets of test data explaining the purpose of each.                                                                                                                                (8)

   A.  - 1,3,-4,6,5
         -To determine how it handles negative numbers.
         - 1,3,4,-6,5
         -To determine whether it chooses the largest number according to magnitude or whether it takes the sign into consideration.
         - 1.5,3,4,5,6
         - To determine whether it can deal with fractions.
         - 1,1,1,1,1
         -To see what happens if the largest and the smallest are the same.
          
Note. There are many more sensible sets of test data that could be used. These are just examples. Make sure that you read the question carefully and give ‘different’ sets of test data. Just changing the data doesn’t make it different, it is the reason for the choice of data that must be different.

11.    Explain the difference between alpha testing and beta testing.                        (2)

   A.  -Alpha testing is done by the programmer or in the software house.
         -Beta testing is done by the user.

12.    Explain how the translator program can issue error diagnostics and give an example of an error that can be spotted by the translator.                                   (3)

   A.  - Translator compares reserved word/syntax (rules) in its dictionary
         - If different to what is in the dictionary the user can be told what and where the error is.
         -eg PLINT is not in the dictionary of words that it knows, so there must be an error.
          
Note. The same example has been used again. I know this one is right, why risk changing it?

13.    Bugs are common in computer programs. Describe two techniques that can be used to help debug a program.                                                               (4)

   A.  - Cross referencing of variables
         - checks the program for occurences of the same variable being used more than once.
         - Trace table.
         - As the program is run the values of the variables are printed out as the instructions are executed, allowing the user to see where sudden, unexpected, changes have occurred.
        
Note. There are lots of possible answers here, always choose the two answers that you are absolutely sure of.

14.a)Describe what is meant by annotation of a program code.                     (2)

   A.  -Explanation of the techniques used in the algorithm
-Needed by people employed to maintain or amend the program in the future…
-by explaining the logic and the reasoning behind the code.

   b)   Describe two methods that can be used to annotate code.                   (4)
         -Indentation of groups of statements.
         -This not only makes the group stand out, but also ensures that the person looking at the code knows which statements should be treated together.
         - Use of sensible variable names.
         -This means that long references to look up tables are not needed and helps to make the understanding of lines of instruction easier to follow.
         
 Note. Again, these are standard answers, but no less effective for that and safe because we know they are going to be right.

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More