Problem set 10
Problem 1: Be sure to turn in your in indata.dat file electronically with your problem set.
Problem 2: If you wish, you can verify that your program works by comparing your checked.dat file with ours: checked-solutions.dat. You do not need to turn in your checked.dat file, but be sure you turn in all the files needed to compile your program (including copies of the files we provided to you).
Problem set 9
Pruning rule #2 has been corrected to be:
2. If (s + Lk + Lk+1 <=M), generate left child (xk= 1)
The incorrect version which used "<" instead of "<="was:
2. If (s + Lk + Lk+1 < M), generate left child (xk= 1)
There was an error in the diagram of the sample tree we provided to you. The Problem Set web page has been updated. Here is the updated tree.
The online version of PS#9 has been updated to reflect these changes.
Problem set 7 - Corrections and Clarifications
- The extra credit is worth a maximum of 40 points, not 20.
- Each stereo has a serial number which is globally unique.
- The product class has two data fields: a type and a serial number.
Correction in Problem Set 6
There is a missing open parenthesis for equation (8). It should appear as follows:
f = a0/(2*a4) – ((k*c*(a2)^2)/(j*(a4)^2*p*v*a0))^(1/3)
Additionally, the variable V (in caps) in the table is the same as v (lowercase) throughout the problem statement.
Problem set 5 - Yet more clarifications for problem 2
Don't call pack() in Problem 2. If you do, the BusDrawing object will become zero-sized.
Problem set 5 - More clarifications for problem 2
The parameter values you see in the screen shot for problem two are slightly incorrect. When input values are 0.0, 0.0, and 1.1 the outputs should be:
Headway: 24.06036392060625
No rtes: 4.628982353197658
Fare: 199.49696732828133
Rider:1306.4757144878142
Revenue: 2606.3794292836847
Cost: 26261.28571024372
For input values of 1.0, 2.0, and 2.0 the outputs should be:
Headway: 26.384317130342872
No rtes: 4.221257630045497
Fare: 755.522762321904
Rider:899.6009530966913
Revenue: 6796.689970710298
Cost: 21402.018114836384
Some students expressed alarm that each time they hit the "calculate" button, the output parameters changed, even with no changes in the input. Fear not, this is the correct behavior. (The bus velocity v depends on its previous value.)
Problem set 5 - Clarification for problem 2
The BusDrawing.java file that we gave you includes a line
double box = BusFrame.Y-200;
You can replace this line with the line:
double box = 300;
Problem set 5
BusDrawing.java is provided. Go to Problem Set 5 on the 1.00 web site and download it from the supporting file.
On problem 1, you may use a single ActionPerformed method with getSource() instead of anonymous inner class.
Problem set 4 clarification for problem 1
You can use integer 'divide by 2' and 'mod 2' operations, but no other divisions and no multiplications. Dividing by 2 is usually supported in simple hardware.
Lecture 10 corrections
Slide 9: 2^5= 32, 2^6= 64
Slide 11: Last identity should be x^2n+1= x*x^2n
Correction in Lecture 9
In exercise 7 on Vectors, replace all [] with ().
Homework 3
Pipe class gravity constant= 9.8 m/sec^2.
Lecture 5
a. In the slides with pictures of objects and references, the BigInteger constructor argument should be in double quotes: BigInteger a= new BigInteger("1000000000000");
b. Don't worry if it seemed like there were a lot of concepts in Lecture 5. There were, and we'll be going over them for the next two weeks. This was an introduction only, but we needed to cover enough so you saw the general picture. We'll revisit all the details in the next set of lectures.
c. The bird simulation is posted on the web under Lecture 5. The simulation works by default with Internet Explorer. For Netscape, you need to install the flashplayer in order to run it. The flash player installer is also posted on the web under Lecture 5/Code.
Assignment 1
You can omit the load per bus calculation from your output for problem.
1) Example values of intermediate calculation (they may have rounding errors):
L0 = 209821.4
E0 = 1092.4
F0 = 3277.3
2) The definition of "Objective weight" (Part 1) should be:
"Used to trade off deficit goals versus ridership goals. As objective
weight increases, ridership and deficit DECREASE. As it decreases,
ridership and deficit INCREASE. This must be strictly greater than 1 and
can increase without limit."
3) We don't declare v as a new variable, so we can change its value through another expression.
Lecture 3
1. In slide 8, "Using Arithmetic Operators", in class DataType2, int d=122, not 123 when it's initialized.
2. Exercises (slide 13): Two corrections:
a. Represent 15*i correctly:
int i= 100000000 + 100000000;
long j= 15L*i; // The 15 must be followed by L. Otherwise 15*i is an int and does not fit
b. Increment int z by int a:
int a=5, z=2;
z += a; // z must be declared and initialized before use with +=
3. Answer to question on slide 19: where is the bug in the quadratic equation program? If the discriminant is -0.000000000000001 (within TOL but negative), the program will incorrectly report no real roots. If the discriminant is +0.000000000000001 then it will correctly report one real root. The correction is to check that the discriminant is within TOL of 0.0 as the first if statement clause in the program.
4. A new copy of DataType2.java is in the Code Examples, and a copy of Exercise1.java has also been placed there, with the correct answers for the exercises in slide 13.
Textbook
"Core Java 2 Volume I--Fundamentals", by Cay S. Horstmann and Gary Cornell, Fourth edition, Sun Microsystems Press.
Bug list for the text: http://www.horstmann.com/corejava/bugs.html