CSCI A201/A597

Lecture Notes 13

Spring 2000


Practical review wrapped up. Midterm review started.

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:

i + j == <constant>
To see this take a walk on any of the lines. You will be visiting cells in the familiar rectangular arrangement. If you go down 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:

What's the sum of i and j in each of these three points?

For A:

therefore
i + j == (size - 1) / 2
is the definition of line [1].

Similarly, line [2] is defined by

i + j == (size - 1)
by looking at B's coordinates. (But we already knew that).

Line [3] is defined as follows:

i + j == (size - 1)/2 + (size - 1)
(You will notice that C has a large 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:

i + j == k + (size - 1)
since C is on the right vertical border (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]:

i - j == (size - 1) / 2 - 0
For [2]:
i - j == 0 - 0 
For [3]:
i - j == 0 - (size - 1) / 2
This is the end of the list of primitive patterns that you will have to know for the practical.

Next, we will discuss a few exercises from QuizSite.

I may post them here later.


Last modified: February 22, 2000 by Adrian German