Homework # 1
due February 3

Reading

Please read Appendix A in your textbook.

Programming

Write a Java program to count the number of distinct variables in a WHILE program. You should use the VISITOR design pattern. Please use the JAR file available in $CLASSHOME/lib/.

My solution runs as follows:


java edu.uwm.cs.cs838.whilex.analysis.CountVariables test.whl
test.whl has 3 variables:
 x z y

Also, write a WHILE program (in the non-extended language) to compute into r the integer square root of the value in variable x. Test your program using the WHILE interpreter edu.uwm.cs.cs838.whilex.eval.Interpreter. Mathematically:


The answers for inputs 15, 16 and 17 should be 3, 4 and 4 respectively.

You should use Newton's method and successively approximate


A tricky part of the assignment is to find the correct termination condition.

Submission

Please put your homework files in your homework1 directory before class time on the due date.

About this document



John Tang Boyland
2009-01-27