



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Part b
. Can you create two instances of the package i.e. a
character queues
and
integer
queues
yes
(^) or
no
)
Part c No
(i)
If
yes
in part b, Define the Ada95 instantiation for a character queue and an
package Character Queue This gets six points even if Parts a, b were wrong.
Queue_Char
is new
Queue(
Item => Character);Size => 5,
package Integer Queue
Queue_Int
is new
Queue(
Item => Integer);Size => 5,
(ii)
If
no
type
Table
(Positive
range
<>)
of
Integer;
Has to be changed to:
type
Table
(Positive
range
<>)
of
Item;
Part d
Modify the Enqueue procedure for a
circular
queue. Include exception handlers to
procedurehandle overflow.
Enqueue (
Element : in
Item )
is
begin
if Tail+1 = Head
then
raise Overflow;
ifTail:= Tail+ 1;-- moves tail to the next locationSpace(Tail) := Element;end if;
then -- make the tail
-- point to first location
exception
when Overflow =>
Put_Line("Circular Queue is full");
end Enqueue;
Name:
from the code shown above. (Answer with one word:
(6 points) (3 points)
integer queue.
in part b, Which line(s) in the specification or body do you have to change?
List the line number and modification to be made.
is array is array
Name:
(16 points)
Hint: How do you check if the queue is full or empty?
Tail := Tail = Size
end if
Name: ________________________________
Name: ________________________________
Prove using induction that the sum of the first
n positive integers is
(^) n(n+1)/*
Fighters and BombersDefine a variant record to holds aircraft information for two different types of aircraft:
1 + 2 + 3 + .. + n = n*(n+1)/
Both kinds of Aircraft have three common fields:
is of type
integer
Call_Sign
is a
string
of maximum 20 characters
Aircraft_Type
is an
enumerated
type with values ‘fighter’ and ‘bomber’
In addition to the three common fields, Fighter Aircraft have fields:
Base Case
Aircraft_Mach
is a
record
(^) with fields
Top_Mach
of type
float
When n = 1,
Cruise_Mach
of type
float
Max_Range
is of type
integer
n*(n+1)/
In addition to the three common fields, Bomber Aircraft have fields:
Crew_Size
(^) of type
positive
Payload
of type
integer
Induction Hypothesis
: Let the theorem be true for j= n.
type Aircraft_Type
is(Fighter,Bomber);
type Fighter_Mach
is record
Inductive Step:
Cruise_Mach : Float;Top_Mach : Float;
When j = n+1, then
end record;
Sum
1 + 2 + 3 + .. + n + (n+1)
type Aircraft_Record(Kind: Aircraft_Type)
is
record
n*(n+1)/2 + (n+1)
[By Induction Hypothesis]
Type : Aircraft_Type; Call_Sign: String(ID : Integer;
((n
2 +n)+ (2n+2))/
[Arithmetic]
(n 2 +3n+2)/
[Arithmetic]
case
Kind is
when Fighter =>
(n+1)*(n+2)/
[Arithmetic]
Aircraft_Mach : Fighter_Mach; Max_Range : integer;
By theorem
Sum
(n+1)*(n+2)/
when Bomber=>
Crew_Size: Positive; Payload : integer;
Hence
end record
end case
For all n
1, the sum of the first
n positive integers is
n(n+1)/*
A fully connected graph withA fully connected graph is a graph in which every node is connected to every other node.
n nodes is denoted by
n .
Base Case
n*(n-1)
Inductive Step: Induction Hypothesis
th
2*n.nodes of the fully connected graph, and hence has degree n. The n nodes of the Kn graph
n 2 +n
(n+1)*n
By theorem
n*(n+1)
∀ Hence n ≥
n (^) nodes=
n(n-1)*
Part a
, given the following hypothesis 1 and 2:
(2 points)
[2,3 Transitivity of ->]
Part b
. Translate the following four sentences of English into the language of predicate
logic.
E(x)
represents x is even, and
O(x)
represents x is odd.
(8 points)
Even(2)2 is even
∃ Not every integer is even x ¬Even(x)
x ∃ y (Even(x) and ¬Even(y))
¬Even(x)If an integer is not even, then it is odd
Odd(x)
Name:
: Let the theorem be true for a graph with n nodes.
When the graph has n+1 nodes, the (n+1)
node has to be connected to the remaining n
have their degree increased by 1. Hence the total increase to the sum of the degrees is
n(n-1) + 2n
[By Induction Hypothesis] Arithmetic]Arithmetic]
Sum of all the degrees of the nodes of a fully connected graph with n+1 nodes is
1, the sum of the degrees of a fully connected graph with
Name:
. Formally prove
contrapositive of 1]
Some integers are even and some are odd
and
next to each question.
Answer
a.
Java
b.
c.
Cobol
d.
Ada
which four?
d.c.b.a.
cyclomatic complexity
b. a.
lower
c.
itself/be executed.
Name:
Simplified Expression is
Name:
Multiple Choice Questions. For each question, select the correct answer from the choices,
write the chosen letter in the box provided
The Niagara, Incremental, Revolutionary, and Spiral modelsThe Waterfall, Incremental, Evolutionary, and Spiral modelsThe Niagara, Incremental, Evolutionary, and Spiral modelsThe Waterfall, Incremental, Acquisition, and Spiral models
describes the asymptoticA theoretical measure used in complexity theory, thatall statements and conditions in a program at least onceNumber of independent paths needed to execute
bound of a function in terms
A measure of the number of times a recursive function will recursively callof another, usually simpler, function