Вы находитесь на странице: 1из 1

Tutorial 1 Programming Language and Algorithm

Question 1
(a) If an integer is defined as one or more digits, write down the BNF grammar for the digit and the
integer.
(b) Using the BNF from part (a) draw the parse tree for an integer.
(c) Use the above to derive that a number 657 is an integer.
(d) Explain the advantages of the extended BNF over BNF. Use appropriate examples to illustrate
your answer.
(e) Write down your definition of an indentifier, its BNF grammar and derive that best1 is an
integer.

Question 2
(a) Explain how the concept of information hiding is implemented in an object oriented
programming language.
(b) Illustrate with appropriate examples the importance of constructors and destructors as member
function of a class.
(c) What are friend functions and classes and how are they important?
(d) What is an ADT and how is it used?

Question 3
a) What do you understand by bound variables in a lambda expression?
b) The lambda expression (x.+x 3) is applied to an expression (+y 3), what is the resulting
expression? Explain the details of the substitutions to arrive at your result.
c) Distinguish between the two expressions (x.*x x) and (y.*y y). What results do they produce
when the following are applied to them (i) the value 5, and (ii) the value (*x 5)?
d) What is the result when the expression (*x x) is applied to the the function y.(x.yx) as follows
y.(x.yx) (*x x)? Explain clearly all the steps of your substitutions.

Вам также может понравиться