Wednesday, March 7, 2007

Notes from Week #8
Mock Suwannatat
7 March 2007

QUIZ

Adapted from:
http://www.andrew.cmu.edu/course/15-111-kesden/index/labs_index.html
Prof Gregory Kesden

Download your "quiz" from:
http://www.contrib.andrew.cmu.edu/user/psuwanna/cs10w07/FCLinkedList.java
http://www.contrib.andrew.cmu.edu/user/psuwanna/cs10w07/Fortune.java

Implement 2 out of 3 blank methods to get a BIG chocolate bar :)
 * - addInOrder
* - getFortune
* - remove

- Mock

Sunday, March 4, 2007

Lab 7 Strategy Session

Monday March 3, 2007
5pm - 8pm
@ Phelp 1413
The show starts at 5:40pm*

This will replace my office hours on Thursday.

* I will be there at 5pm. I will be eating my dinner and answering your questions. I will start talking about Lab 7 Strategy at 5:40pm. The talk may be about 60 - 90 mins.

Tentative Outline
  1. The math needed
    For those who already know how to write this program but get stuck on Math.
  2. How spiral example works
    Understanding how the spiral application (in the book) works.
  3. Basic hints
    Aimed at putting you in the right mindset to do the lab yourself. If you don't want to spoil the challenge, you should leave after this.
  4. More hints
    More detailed hints, suggested design. Warning: the fun could be spoiled. But you still need to understand what's going on in order to write the code.
  5. Even more hints? Nah... But let's look at some other examples.
    What if the lab is a Sierpinski Gasket? or a fractal tree?
  6. Questions

I can stick around a little after 8pm if people need me.

- Mock

Friday, March 2, 2007

Lab7 FAQ (part I)

Lab7 FAQ (part I)

Q1: A snowflake looks like a (fancy) triangle. But each smaller part is not a triangle. How do I use recursion to solve the problem?
Answer:
We do not draw a big triangle. Instead, we call the method 3 times (with different vertices as argument) to draw 3 segments of the snowflake.

Q2: What is really being executed? If we call ourselves all the way down to the littlest point, we don't really have a reason to come back up(up the call ladder) because we are just drawing small lines.
Answer:
At the bottom level of recursion, we know what to draw, so draw. For this program, we do not start drawing anything until we get to the bottom. What's the point of backing up the "call ladder"? So we can draw other small segments that make up for other parts of the snowflake. Even though the upper (non-bottom) levels of recursion do not draw anything, they actually calculate the positions and make calls to the lower level.

Q3: How would recursion work with the snowflake? How does recursion draw the lines and cuts out the old section?
Answer:
Again, there is no "cutting out" any lines here. It's unlike the spiral (or the Sierpinski Gasket) where we performs a draw at each level. For this lab, we only draw at the bottom level (base case of recursion).

Q4: I write a class called SnowflakeSegment. What should be the arguments to the constructor?
Answer:
Up to you. I have 2 suggestions for you. Choose either one or come up with your own. There is no right or wrong.
  1. SnowflakeSegment(Point p1, Point p2);
  2. SnowflakeSegment(Point p1, double length, double angle);
Both options would give sufficient information to the SnowflakeSegment on what to draw. Which one should you pick? ... whatever. You will need to calculate the points of subdivision from the arguments. It's a little work on geometry. Both options give you enough information for the calculation.
If you have more questions, post them here (be sure to put your name) or email me.

- Mock

Lab 7 Strategy Session

Dear cs10 Students,

Lab 7 seems to be tricky to many people, although it will not be much of a code change from the spiral example. I encourage you all to start early.

At least, please (please, please) read the lab and try to understand the example code by this weekend. Type it in your computer, run it, appreciate it, modify it to look differently. Play around with it. Try to understand how the code works.

Next, please read my Notes for Week #7 (previous post). Toward the end, I wrote about Sierpinski Gasket (which I didn't get to in the session yesterday). This, together with the spiral example in the book, can provide an insight into how you approach your lab.

Now, I would like to take a vote from you. If you care (:P), please reply to this email with answers to the following questions:
[1] Should I reschedule my office hours next week to Monday?
[2] If so, what time on Monday works for you?

I will call it a "Lab 7 Strategy Session" where I will provide "incremental hints" to those who need. You can come in, take some ideas, and leave (so you won't be spoiled by the hints). Or you can stick around to see more concrete examples of (other similar kinds of) fractals.

Have a nice weekend :)
- Mock

Contributors