-- Adrian
> One question about assignment 6. In order to use the Edge type, we need
> to treat it as a 2-element array, correct? And in order to do that, we
> need to declare any variables of type Edge as "Edge blah = new
> int[2]".
This assumption is INCORRECT. Edge is just an interger pointer. In other
words it is just a reference to a particular element in the matrix array.
For example, given a 5x5 array matrix, ie. matrix[25], if I want a
reference to an element in matrix array, say matrix[4], then I would have
Edge blah = &matrix[4], which give the address of that array element.
Keep that in mind, each element in the matrix is a possible edge. Even
though the matrix array is a one-dimension array, you are supposed to
treat it as a two-dimension array, and the two-dimension indices of the
matrix array element is your pair of intergers connected by the edge
represented by that element.
.--------..------------..--------..-----------------------..--------.
| o\ /o || John C Wu || o\ /o || Engineering Science || o\ /o |
| ---- || || ---- || University of Toronto || ---- |
`--------'`------------'`--------'`-----------------------'`--------'
"Memory is like an orgasm. It's a lot better if you don't have to fake it."
Seymour Cray commenting on virtual memory
> This assumption is INCORRECT. Edge is just an interger pointer. In other
> words it is just a reference to a particular element in the matrix array.
We have to write functions that return an edge's vertices. How would we
do this if Edge only points to an array element? I guess what I'm asking
is how we relate the pointer's value to the array index.
As what I said in the previous response, even though matrix is a
one-dimensional array, you are supposed to treat it as a two dimensional
array. In two D, you will need two numbers to reference an element, and
those two numbers are your vertices connecting the edge. the Edge pointer
value allows you to resolve the one D index of the element in the one-D
arrary, after which you are supposed to use it to resolve the two-D indices
of that element. Read the code in the book, and go to the lab on Monday
morning to talk to a TA.
John C Wu
As what I said in the previous response, even though matrix is a
one-dimensional array, you are supposed to treat it as a two dimensional
array. In two D, you will need two numbers to reference an element, and
those two numbers are your vertices connecting the edge. the Edge pointer
value allows you to resolve the one D index of the element in the one-D
arrary, after which you are supposed to use it to resolve the two-D
indices of that element. Read the code in the book, and go to the lab on
Monday morning to talk to a TA.
.--------..------------..--------..-----------------------..--------.
> Hey,
>
> > This assumption is INCORRECT. Edge is just an interger pointer. In other
> > words it is just a reference to a particular element in the matrix array.
>
> This is nowhere in the assignment description. It does not make sense to
> change the scope of the assignment and make it much more difficult that it
> has to be the day before it's due. I do not like this form of
> neo-terrorism and I'm going to implement a 2-element array.
>
The comment I made earlier in responding to a newsgroup question was
meant to help you understand the problem. It was by no means meant to
change the scope of the assignment. The comment made was based on my
understanding of the assignment by doing it myself. Maybe, the word
"INCORRECT" was a bit too strong there. But, I don't know if the
2-element array approach would make the problem any easier to implement or
to understand though.
> This assumption is INCORRECT. Edge is just an interger pointer. In other
> words it is just a reference to a particular element in the matrix array.
This is nowhere in the assignment description. It does not make sense to
change the scope of the assignment and make it much more difficult that it
has to be the day before it's due. I do not like this form of
neo-terrorism and I'm going to implement a 2-element array.
Don McAuslan
=================================================
"Why does a femme gino need firearms?"
don.mc...@utoronto.ca
=================================================