CSci 169 Homework Assignment - Software Paradigms - Fall 2007 - Prof. Abdelghani Bellaachi, Assignments of Computer Science

A homework assignment for the course csci 169 - software paradigms at the george washington university, school of engineering and applied science, department of computer science. The assignment includes problem statements for drawing a parse tree, extending a grammar, implementing a matrix template, and analyzing a c2 type language. Students are required to submit their solutions by october 22, 2007.

Typology: Assignments

Pre 2010

Uploaded on 08/16/2009

koofers-user-eqr
koofers-user-eqr ๐Ÿ‡บ๐Ÿ‡ธ

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
The George Washington University
School of Engineering and Applied Science
Department of Computer Science
CSci 169 โ€“ Software Paradigms โ€“ Fall 2007
Homework Assignment
Due Date: October 22, 2007
Instructor: A. Bellaachia
Problem 1: (25 points)
E :: E โ€˜+โ€™ T | T
T :: T โ€˜*โ€™ F | F
F :: โ€˜(โ€˜ E โ€˜)โ€™ | int
a) Draw the parse tree of (((3)))
b) Extend the grammar with the following construct: if-then-else statement
The following examples should be accepted by your extension.
If true then:
a=5;
b=c;
:else:
toto=4;
foo=0;
:
If true then:
a=5;
b=c;
:
If true then:
a=5;
If true then:
www=5;
:else:
toto=4;
foo=0;
:
Problem 2: (25 points)
Create a template to manipulate matrices. You template should include the following operation:
- Addition, Multiplication, Subtraction, and Transpose
(a) Implement you template using both java and C++
(b) Send you code to [email protected] and to me.
Problem 3: (25 points)
Problem 1: Do problem 29 on page 171 of your textbook.
Problem 4: (25 points)
Given the following C2 type language:
sub2(int x) {
int c = 10;
Return (x +c);
}
sub1(int i, int j) {
If (i<=j)
return i
else
return(sub2(j))
}
main() {
int n, m;
get(n, m);
print(sub1( m, n));
}
a) Give the SIMPLESEM code for this program.
b) Show the final state of your machine for n=3 and m = 5
c) Show the final state of your machine for n=5 and m = 3

Partial preview of the text

Download CSci 169 Homework Assignment - Software Paradigms - Fall 2007 - Prof. Abdelghani Bellaachi and more Assignments Computer Science in PDF only on Docsity!

The George Washington University

School of Engineering and Applied Science

Department of Computer Science

CSci 169 โ€“ Software Paradigms โ€“ Fall 2007

Homework Assignment

Due Date: October 22, 2007

Instructor: A. Bellaachia Problem 1 : (25 points) E :: E โ€˜+โ€™ T | T T :: T โ€˜*โ€™ F | F F :: โ€˜(โ€˜ E โ€˜)โ€™ | int a) Draw the parse tree of (((3))) b) Extend the grammar with the following construct: if-then-else statement The following examples should be accepted by your extension. If true then: a=5; b=c; :else: toto=4; foo=0; : If true then: a=5; b=c; : If true then : a=5; If true then : www=5; :else: toto=4; foo=0; : Problem 2: (25 points) Create a template to manipulate matrices. You template should include the following operation:

  • Addition, Multiplication, Subtraction, and Transpose (a) Implement you template using both java and C++ (b) Send you code to [email protected] and to me. Problem 3: (25 points) Problem 1: Do problem 29 on page 171 of your textbook. Problem 4: (25 points) Given the following C2 type language: sub2(int x) { int c = 10; Return (x +c); } sub1(int i, int j) { If (i<=j) return i else return(sub2(j)) } main() { int n, m; get(n, m); print(sub1( m, n)); } a) Give the SIMPLESEM code for this program. b) Show the final state of your machine for n=3 and m = 5 c) Show the final state of your machine for n=5 and m = 3