Quiz 1

One-page version suitable for printing.

Statistics:

mean     21.750 (261.000/12)
stddev   7.037
median   24.000
midrange 16.000-27.500

#   avg
1   11.50 / 15
2    5.92 / 10
3    4.33 /  5

Question 1-1

Prove the following using our axiomatic scheme.

{ i * k = n AND k mod 2 = 0 }
k := k / 2;
i := i * 2;
{i * k = n }

Solution

Question 1-2

Consider the following Ada program.

with Text_IO; use Text_IO;
procedure Test is
    X : Integer;

    procedure A is begin
        X := 3;
    end A;

    procedure B is
        X : Integer;
    begin
        X := 4;
        A;
        Put_Line(Integer'Image(X));
    end B;
begin
    X := 2;
    B;
    Put_Line(Integer'Image(X));
end Test;

Solution

Question 1-3

Consider the following grammar.

S -> a S b S | x
Draw a syntax tree for the sentence
a a x b x b x