**NOTES:**

- If the TAs cannot read your name, you cannot get credit for your work! Please use computer printed output if at all possible, and if not, please write very clearly. Unreadable work will not be counted.
- Please hand in homework in paper hardcopy form; do not email me or the TA an attachment! Computer printed paper is much preferred; if your handwriting is too hard to read, you will lose points. You may also lose points if your solution is too difficult to understand, whether due to English or technical problems.
- Please give the assignment set number and problem number for each question; also be sure to include your name, and the due date. If there are multiple pages, you should staple them; since there are many students, loose pages are likely to be lost, and you will not get credit.
- For problems that require use of a computer, always hand in both your input and your output as part of your solution.
- Please do not ask the TAs or professor for help doing your homework; this is not fair to other students. Especially, please do not do so in a sneaky way; we have all been deluged with such questions by email, and from now on we will take off points if you ask them. Of course, it is acceptable to ask questions about the content of the course - indeed, it is encouraged! And you can also ask about bugs in the homework questions (if there are any).
- Assignments will normally be posted by Friday, due on Tuesday of the following week. Homework due more than 5 days away is subject to change.
- Every problem you hand in will be checked, but only a random subset (chosen to be maximally helpful to you, subject to our resource limitations) will be graded; you will get up to 3 points for a problem that is handed in and checked, and up to 10 points for one that is graded; of course, the total for homework will be weighted appropriately when combined with the midterm and final.
- Be sure to reload pages frequently, because sometimes they may be updated frequently (i hope this is unnecessary since I have put meta tags on pages, but it is not guaranteed).

- Due 17 January:
- An
**acyclic graph**is a graph with no cycles, where a**cycle**is a (non-void) path from a node to itself. Write a formal definition for acyclic graph, based on one of the two definitions of graph given in class (using the formal notation of set theory and logic). Give an example of an acyclic graph that is not a tree. - Say what is your favorite programming language, and explain why you
like it, without falling into merely subjective considerations; i.e., you
should base your argument on real historical, cultural, and pragmatic
considerations, such as those described in the
*Essay on Comparative Programming Linguistics*. Give sample code illustrating your main points. - Exercise 1.9 of Sethi (p. 22). Justify your answer.

- An
- Due 24 January:
- Given the grammar
E ::= E + E | E * E E ::= X | Y E ::= 0 | 1 | 2 say how many distinct parses there are for`X + Y * 2 + 0`and give a proof that your answer is right. How many distinct values are there (under the standard interpretation of the operations) for these parses? - Give an unambiguous grammar that generates exactly the same expressions as the above grammar, and explain why it is unambiguous.
- Give a BNF grammar (do not use extended BNF) for the language of
expressions consisting of an odd number of
`a`'s followed by an even number of`b`'s. For example,`aaabb`and`abb`are in the language, but`ab`and`aa`are not. Draw a syntax chart for your grammar. - Exercise 2.8 of Sethi (p. 49). Include drawings of stack states in your evaluation of the given expression. Can the same be done for prefix?

- Given the grammar
- Due 31 January:
- Exercise 3.7 of Sethi (p. 96).
- Give pre- and post- conditions for code to compute the Nth prime number. Write Pascal while-do code with loop invariants; pseudo code is OK. Hints: You may find the predicate P(K) = "A[I] is the Ith prime for 1 <= I <= K" useful in your assertions; you may also want to treat N=1 and N=2 as special cases; only two loops are needed, one nested in the other. The Seive of Eratosthenes algorithm may be useful (and the applet at this link is cool).
- Do Bentley's problem in Example 3.4 on page 81; give informal invariants and show how they help develop your code and improve its chances of being correct.

- Due 7 February:
- Write complete (pseudo) Pascal code (including declarations) to produce linked list structures as in Figure 4.10, page 128, from a sequence of user intput integers.
- Write complete Pascal (pseudo) code (including declarations) to test for equality of linked list structures as in Figure 4.10, page 128.
- Write complete Pascal (pseudo) code (including declarations) to produce structures like those in Figure 4.13(a), page 131, and then swap them, as in Figure 4.13(b).
- Exercise 4.3 of Sethi (p. 143).
- Give examples showing that the three kinds of type equivalence (on page 140) are pairwise different.

- Due 14 February:
- Write a paragraph or two on the most significant differences between Pascal and C, and explain which differences are well motivated by the different main uses of these languages.
- The mathematical definition of Fibonacci numbers is: f(0) = 0, f(1) = 1, f(n) = f(n-1) + f(n-2) for n>= 2. Write Pascal pseudo code for this function, and show the activation tree and activation records for the computation of f(3).
- Exercise 5.1 of Sethi (p. 198), with "snapshots" showing how the values in cells change in each case.
- Exercise 5.2 of Sethi (p. 198-99).
- Exercise 5.3 of Sethi (p. 199), with "snapshots" showing how the values in cells change in each case.

- Due 28 February: Warning: this is tentative.
- Exercise 6.4 of Sethi (p. 248); use pseudo code.
- Exercise 6.6 of Sethi (p. 249); include some snapshots of its execution.
- Exercise 6.11 of Sethi (p. 250); hand in source code and output showing that the compiled code executes correctly on some not totally trivial examples, and give an invariant for the loop.
- Something for Chapter 8 here.
- Something for Chapter 8 here.
- Something for Chapter 8 here.

Standard ML of New Jersey is available on ACS machines such as

`sml`

, or else you can
add the path for its directory to the `PATH`

variable of your
environment; however, this may not work from all machines, and may not work
for undergraduates. If none of this works for you, you can download the
latest version of ML (version 110.0.7) over the web from www.smlnj.org/software.html or
cm.bell-labs.com/cm/cs/what/smlnj; another alternative is the OCAML
variant of ML.
Binary for BinProlog 4.00 for Solaris machines (such as the CSE
instructional machines beowulf, bintijua, kongo, or the machines in the APE
lab) can be found at **/net/cs/class/wi99/cse230/prolog/bp**, and also as
a backup, at **/net/cat/disk1/prolog/bp**; the latter directory also
contains other files, some of which may be relevant to exercises, so that you
don't have to do all the typing yourself. Some basic notes on using
BinProlog 4.00 are at **binpro.html**.

To CSE 130 homepage

Maintained by Joseph Goguen

© 2000 - 2006 Joseph Goguen

Last modified: Sat Feb 18 13:10:59 PST 2006