| CSCI A201/A597Lecture Notes 13 Spring 2000 |
There's a real practical exam coming up this week. We finish reviewing the material for it today. There will be two new homework assignments posted later this week, one will be another (slightly different) set of multiple-choice items to help you with midterm preparation. Once posted it will be due right before the midterm exam.
The other homework assignment will be demonstrated in class today but won't be due until the end of the lab before the Spring Break. Today we cover two more patterns for the practical and discuss some of the most difficult items in the Week5 batches.
Extra Pattern 1
All these three lines (angled at 45o) have the same property:
To see this take a walk on any of the lines. You will be visiting cells in the familiar rectangular arrangement. If you go downi + j == <constant>
i is
increasing, and j is decreasing (since you're also moving to
the left). If you go up then i will be decreasing but you'll
be moving to your right, so j will assume higher values.
The constants that we are looking for can be found out if we add
i and j at some convenient points:
[1] A is such a point
[2] B is such a point
[3] C is such a point
i and j in each of these
three points? For A:
i == 0
j == (size - 1) / 2
is the definition of linei + j == (size - 1) / 2
[1].
Similarly, line [2] is defined by
by looking at B's coordinates. (But we already knew that).i + j == (size - 1)
Line [3] is defined as follows:
(You will notice that C has a largei + j == (size - 1)/2 + (size - 1)
j and a non-zero i).
In general your line is either below or above the second diagonal and you have a clear
point on the border that you want to connect. Use that point for the constant value that
the sum of i and j should have. For example in the more general
case that is illustrated below we assume we know that C is situated k lines
below the top horizontal line.
In this case the blue line has the following definition:
since C is on the right vertical border (i + j == k + (size - 1)
j has its max value). If C were
to be on the top horizontal line then j would have to be known, since the
value of i would be 0.
Extra Pattern 2
For this the traick is to realize that when you follow any of the diagonal
lines when i is increasing j is increasing by
the same amount, and when i is decreasing j
is decreasing by the same amount. We can verify these by looking at the
movement from one cell to the other in either direction: NW or SE.
So the difference between them will remain constant. For this reason the three lines in the picture can be defined as follows.
For [1]:
Fori - j == (size - 1) / 2 - 0
[2]:
Fori - j == 0 - 0
[3]:
This is the end of the list of primitive patterns that you will have to know for the practical.i - j == 0 - (size - 1) / 2
Next, we will discuss a few exercises from QuizSite.
I may post them here later.