



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!




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.
(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
FSA Regular expression
& P
CX } \D
, )
(8) 3. Use the BNF provided to develop a parse tree for the variable a!2[b,c3].
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
1-value r-value decimal value
(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
(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]) =