Docsity

CMSC 330 Midterm Exam Questions - Prof. David G. Preston, Exams of Programming Languages

Toggle sidebar
bg1
Midterm
Exam
CMSC
330
Sections
0201, 0202
T>
(^Jt,
7^
S7D/V
15
October
1998
i/
Point
total:
100
NAME
IN
L
V
____________
(please
print)
The
point
value
for
each
question
is
indicated
(in
parentheses).
Do
your
own
work;
use
your
time
wisely.
(16)
1.
On
the
line
provided, write
the
letter
corresponding
to
each
statement
below
that
is
TRUE.
a.
High-order
artificial
intelligence
languages
were
developed
prior
to
high-order
systems
languages.
b.
A
goal
of
early
FORTRAN
was
run
time
efficiency.
c.
A
goal
of
early
LISP
was
run
time
efficiency.
d.
Dropping
obsolescent
or depracated
features
from
languages
is
beyond
the
scope
of
language
standardization.
e.
Program execution
is
easier
to
trace
in
interpreted
languages
than
in
compiled
languages.
f.
Program execution
is
more
efficient
in
interpreted
languages
than
in
compiled
languages.
g.
The
binding
time
for
variables
to
values
is
language
implementation
time.
h.
The
binding
time
for
real
numbers
to
their implementation
is
language
implementation
time.
L^-Trlib
binding
time
of/ianguage
co^troLdtructupes
tc/theij/'sern-an
tj^s
is/lar)£ua£e/
irrtpleraer/mtion
time.
^
'
1
f
}.
Two
language
types,
or
paradigms,
are
imperative
and
applicative.
k.
A(I,J)
may
be
either
an
array
reference
or
procedure
call;
therefore
it
is
orthogonal.
1.
All
modern
programming
languages
have
the
same
primitive
data
types.
m.
Using
linked storage
for
a
data
structure
(as
opposed
to
sequential
storage)
enables
random
selection
of
data
elements
by
calculation.
n.
A
dangling
reference
happens
when
all
access
paths
to
a
data
structure
have
been
destroyed
but
the
data
v
structure
persists.
o.
One
common
approach
to
storage
for
a
variant
record
type
is
to
allocate
adequate
storage
for
the
larger
variant
for
all
records
of
that
type.
p.
An
ordered
acquencraf
daia
St
rucnnwt»a4«t.
s<2r
i
'
pf3
pf4
pf5

Partial preview of the text

Download CMSC 330 Midterm Exam Questions - Prof. David G. Preston and more Exams Programming Languages in PDF only on Docsity!

Midterm Exam CMSC 330 Sections 0201, 0202 T> (^Jt, 7^ S7D/V 15 October 1998 i/ Point total: 100 NAME IN L V ____________ (please print)

The point value for each question is indicated (in parentheses). Do your own work; use your time wisely.

(16) 1. On the line provided, write the letter corresponding to each statement below that is TRUE.

a. High-order artificial intelligence languages were developed prior to high-order systems languages. b. A goal of early FORTRAN was run time efficiency. c. A goal of early LISP was run time efficiency. d. Dropping obsolescent or depracated features from languages is beyond the scope of language standardization. e. Program execution is easier to trace in interpreted languages than in compiled languages. f. Program execution is more efficient in interpreted languages than in compiled languages. g. The binding time for variables to values is language implementation time. h. The binding time for real numbers to their implementation is language implementation time. L^-Trlib binding time of/ianguage co^troLdtructupes tc/theij/'sern-an tj^s is/lar)£ua£e/ irrtpleraer/mtion time. 1 f ^ ' }. Two language types, or paradigms, are imperative and applicative. k. A(I,J) may be either an array reference or procedure call; therefore it is orthogonal.

  1. All modern programming languages have the same primitive data types. m. Using linked storage for a data structure (as opposed to sequential storage) enables random selection of data elements by calculation. n. A dangling reference happens when all access paths to a data structure have been destroyed but the data vstructure persists. o. One common approach to storage for a variant record type is to allocate adequate storage for the larger variant for all records of that type. p. An ordered acquencraf daia Strucnnwt»a4«t. s<2ri '

(8) 2. Give EITHER the regular grammar OR the finite state automaton OR the regular expression for the following:

the set of all strings over {a,b} that do NOT contain the substring aba

Regular grammar

(DO ONLY ONE OF THESE)

FSA Regular expression

& P

'OY^^CO

CX } \D

, )

(8) 3. Use the BNF provided to develop a parse tree for the variable a!2[b,c3].

::= [] ::= | | ::= { , }* ::= a |b I c Id ::=0 | 1 |2 3 |4 5 6 1 8 |

a 1 2 [ b ,' c 3" ]" (Blanks should be ignored; they are inserted to facilitate a legible parse tree)

V (8) 4. Generate the finite state automaton for the regular grammar below:

A -> aA | bB | c FSA B -> bB cA I a

(8) 8. Use the PL/1 fixed-point declarations, the r-values provided, and the two assignment statements to calculate the indicated r-values and decimal values.

DECLARE V FIXED DECIMAL (10,3) W FIXED DECIMAL (10,2) X FIXED DECIMAL (10,1) Y FIXED DECIMAL (10,2) Z FIXED DECIMAL (10,1)

1-value r-value decimal value X 0000567800 S£78o« Q Y 0000567800 Z 0000567800 S"k~78Q»Q

W = X + Y

v-x + z

1-value r-value decimal value

w fea^Boo fe^s~B

V 11,35^0000 U3S"4>Q

(8) 9. Indicate whether the following statements would be VALID or INVALID if the language used name equivalence and if the language used structural equivalence for data types.

type A: array[1..10] of integer; B: array[1..10] of integer; var a, b:A; c:B; procedure C(d:A); name structural equivalence equivalence

a:=b a:=c a[2]:=c[2] a[2]:=c[4] C(a)

(20) 10. Use the following Pascal-like declaration and statements for parts a, b, c:

var A: array [0..2,-!..0,2..3] of integer;

fori:=0 to 2 do forj := -1 toO do for k := 2 to 3 do

Assume the following: 4 integers take one memory location

  • descriptors include the virtual origin and the upper and lower bounds and multiplier for each dimension
  • descriptor for A begins at location 1000 and the storage for array A at 2000
  • A is stored in row major order

(a) Fill in the relevant sections of the following memory map and give the access formula forA[ij,k].

NAME VALUE NAME VALUE 1000 VO c3'OGQ 2000 ftt^lLjO - 1001 L-gc Q 2001 ft IP H, 33 -<f 1002 u3i «3 2002 Pyto,o,z^ -a 1003 mi 1 2003 fr to.o. 3^ - 1004 L-BJ -/ 2004 ft-lA-l.gJ ~a (^) " 1005 q^q O 2005 frO-l.-sl ' 1006 (V\A oi 2006 1007 L^% g 2007 1008 UB y 3 2008 A-T3.- 1009 f\Jfr / 2009 1010 _____ _____ 2010 1011 _____ _____ 2011 1012 _____ _____ 2012 1013 _____ tf _____ 2013 1014 _____ V _____ 2014 1015 2015

Access formula: l-value(A[i j,k]) =