Area B 3 Object-Oriented Programming A software engineer is utilizing a cut-down variant of Java that doesn't
Question:
Area B 3 Object-Oriented Programming A software engineer is utilizing a cut-down variant of Java that doesn't uphold static fields or then again legacy (neither broadens nor carries out). Static techniques and static inward classes are as yet upheld. (a) What are the ramifications of this for static techniques as far as: (I) admittance to static fields; and [1 mark] (ii) access modifiers. [1 mark] (b) Describe how a developer could utilize a common case of a climate object to copy static fields. Consider: (I) dividing state among all cases of a class; [4 marks] (ii) access-modifiers; and [6 marks] (iii) initialisation. [4 marks] (c) What are the disadvantages and advantages of your plan contrasted with static fields?
For every one of the accompanying language regions make sense of what Java gives and analyze it
with the closest comparing highlight in ML (for each situation seeing the dialects
as far as the parts of them canvassed in the Part IA address courses):
(a) the crude information types gave; [3 marks]
(b) exemptions: proclaiming, raising and dealing with them; [3 marks]
(c) having a capacity call, say f(x), do various things in view of the real
contention being one of a few potential minor departure from some kind of information type.
[4 marks]
4 Operating Systems
(a) What is an intrude? [1 mark]
(b) An equipment gadget wishes to move data to the primary memory of the
PC for access by an application. The accompanying three components are
accessible:
(I) surveyed mode activity;
(ii) modified I/O;
(iii) direct memory access (DMA).
For every one, sum up its activity and propose a benefit it holds over
the others.
[3 imprints each]
3 [TURN OVER
CST.2002.1.4
Segment B
5 Foundations of Computer Science
This question concerns the accompanying ML revelation of a tree datatype:
datatype 'a fan = Wave of 'a * ('a fan) list;
(a) Declare the capacity flip, which maps a tree to an identical representation of itself, as
outlined: [3 marks]
2 1 3 4
1
5 6
1
4 2
6 5
3
(b) Declare the curried work paint f, which duplicates a tree while applying the
work f to every one of its names. [3 marks]
(c) Declare the capacity same shape, which analyzes two trees and brings valid back
assuming they are equivalent with the exception of the upsides of their marks and in any case returns
bogus. [5 marks]
(d) State the sorts of capacities flip, paint and same shape. [3 marks]
(e) The capacity paper is announced as far as the recognizable utilitarian foldr:
fun foldr f ([], e) = e
| foldr f (x::xs, e) = f(x, foldr f (xs,e));
fun paper (Wave(x,fs), q) = foldr paper (fs, q+1);
Depict the calculation that outcomes when paper is applied to a tree.
[6 marks]
4
CST.2002.1.5
6 Foundations of Computer Science
(a) Explain how O-documentation is utilized to communicate effectiveness of calculations. [5 marks]
(b) Arrange the accompanying rundown of intricacy classes arranged by diminishing productivity
in n. Momentarily legitimize every relationship.
O(5n
2
) O(e
n
) O(n
1/3
) O(n
3 − 3n
2
) O(log n) O(n2
n
)
[4 marks]
(c) Suppose that f is a capacity from numbers to whole numbers with the end goal that I 6 j infers
f(i) 6 f(j). Then, at that point, there is an effective calculation to address the condition f(k) = y,
given the ideal y and a scope of values in which to look for k: the thought
is over and again to split this reach. Code this calculation as the ML work
search whose contentions are f, y, and the reach (a, b). Its outcome ought to be
the best k with the end goal that f(k) 6 y and a 6 k 6 b, gave such a k exists.