**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 11 January:
- Briefly compare Java with at least three other languages, such as FORTRAN, COBOL, BASIC, Algol, C, Lisp, ML, Ada, C++, etc; the languages that you choose for comparison should be very different from each other; write one paragraph for each comparison; please try to hit the main points and avoid the trivial points.
- Say what is your own 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*. - Exercise 1.10 of Sethi (p. 22). First show how to translate the two new RAM instructions into code using only the original instructions.

- Due 18 January:
- Given the grammar
E ::= E + E | E * E E ::= X | Y | Z E ::= 1 | 2 | 3 say how many distinct parses there are for`X + Y * 2 + Z`and give a proof that your answer is right. - 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 even number of
`a`followed by an odd number of`b`. For example,`aaaabbb`and`b`are in the language, but`ab`and`bb`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.

- Given the grammar
- Due 25 January:
- Exercise 3.3 of Sethi (p. 95).
- Give a pre- and post- conditions for code to compute both the remainder and the quotient for x divided by y. Expand the while-do code on page 81 to compute these, and add the loop invariant.
- Do Bentley's problem in Example 3.4 on page 81; give informal invariants to develop your code and improve its chances of being correct.

- Due 1 February:
- Write complete (pseudo) Pascal code (including declarations) to produce the list (1 2 3 4) using the linked list structure in Figure 4.10, page 128.
- Write complete (pseudo) Pascal code (including declarations) to produce the structures in Figure 4.13(a), page 130, and then swap them, as in Figure 4.13(b).
- Exercise 4.2 of Sethi (p. 143).

- Due 8 February, but you may hand in up to 15 February:
- Exercise 5.1 of Sethi (p. 198), with "animations" showing how values in cells change in each case.
- Exercise 5.3 of Sethi (p. 199); use "animations" of values in cells in your explanations.
- Exercise 5.4 of Sethi (p. 199).

- Due 21 February:
- Exercise 6.1 of Sethi (p. 248). Write the code in pseudo-C, and include some animations of its execution.
- Exercise 6.3 of Sethi (p. 248); hand in source code and output showing that the compiled code executes correctly on some not totally trivial examples. You may use Java or C++ as you prefer.
- Exercise 6.5 of Sethi (p. 248-9). Include informal arguments that the invariants hold.

- Due 1 March:
- Exercise 8.1 of Sethi (p. 335).
- Exercise 8.5 of Sethi (p. 336).
- Exercise 8.13 of Sethi (p. 338).

- Due 8 March: You should run your code and hand in the output for two test
cases for each part of each question where applicable.
- Exercise 9.6 of Sethi (p. 381).
- Exercise 9.7 of Sethi (p. 381).
- Exercise 9.11 of Sethi (p. 381).

- Optionally due 15 March: These problems will not be graded but will help
you prepare for the final; you can take solutions to the TAs office hours to
get feedback if you wish. The code should be executable and each answer
should include output for two test cases for each part of each question.
- Exercise 11.2 of Sethi (p. 470).
- Exercise 11.4 of Sethi (p. 471).
- Exercise 11.5 of Sethi (p. 471).
- Exercise 11.7 of Sethi (p.471).

**Note:**You may use a different Prolog than BinProlog if you prefer.

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 - 2005 Joseph Goguen

Last modified: Thu Mar 10 15:00:57 PST 2005