Public Group

# Ron Penton Data Structures book

This topic is 5080 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Can someone explain why Penton treats a 2D array such as: a[4][3] like I would treat a[3][4]. At first I thought it was a mistake (page 115) but he does this multiple times throughout the chapter (page 124).

##### Share on other sites
could you be a little more clearer?
maybe with some pseudocode or something?
cuz obviously you and him treat rows and columns differently.

##### Share on other sites
Sorry!

He shows this after "a[4][3] = 10" :

Shouldn't this be a[3][4]? He is writing his own 2DArray class so perhaps this is how his implementation works but I just don't see it. If someone with the book could explain what he is doing here I would appreciate it.

And on page 124 he draws a 4x5 array with 5 rows and 4 columns. Just backwards to how I'm used to thinking about it.

##### Share on other sites
I LOST MY DENTAL FLOSS!

##### Share on other sites
//Edit: nm, I'm talking bs

[Edited by - Luctus on January 16, 2005 2:38:12 AM]

##### Share on other sites
HughG: it doesn't matter which order you take, as long as you are consistent with your choice. A two dimensional array is just that: an abstract field of 2D data. The attribution of rows and columns to indices is purely arbitrary, there is no fixed notation of "this is X, and this is Y". A[x][y] is just as valid as a[y][x], as long as you don't mix both. It's a matter of preference.

It starts to matter when treating the 2D array as a matrix (the swapping of the index axes is called 'transposing' there), but in the simple case of a two dimensional grid, just use whatever notation you prefer and stick with it.

##### Share on other sites
To add to the subject, I agree with Yann, it is all in how you use the array that matters...

Quote:
 Original post by Luctus... In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move ...

ROFLMFAO!!!!! This is the funniest quote I have ever heard! Has replaced my favorite from Einstein... "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."

##### Share on other sites
Quote:
Original post by Raisor
Quote:
 Original post by Luctus... In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move ...

ROFLMFAO!!!!! This is the funniest quote I have ever heard! Has replaced my favorite from Einstein... "Only two things are infinite, the universe and human stupidity, and I'm not sure about the former."

Yeah, I agree with you there. I told it to my friend one time and he was just like "...okay", I thought it was hilareous but no one else seemed to really get anything out of it.

##### Share on other sites
It has to be a misprint. Your right about the picture, it should correspond to
a[3][4] = 10;
Because the first subscript is the number of arrays, which is the same as saying the amount of rows.

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633710
• Total Posts
3013482
×