**A 2 dimensional matrix is similar to a 2-dimensional array. An M by N matrix has M rows, each of which has N columns. Thus the individual elements can be indexed directly by a row number and a column number.**

**In some programming languages, such as C and C++, matrices can easily be implemented as an array of arrays. For example, consider an M by N matrix X. In this case, X is a length M array of pointers. Each pointer allows you to access a different row -- a length N array. You can access the pointer to the i-th row using the notation X[i], and you can access the j-th column of the i-th row using the notation X[i][j].**

Henry came from a long line of soccer stadium peanut vendors. As such, Henry was introduced to the concepts of matrices and matrix indices at a very early age. By the time he was six years old, Henry could accurately throw a bag of peanuts to any matrix location with his eyes closed. By the time he was seven, he could do that in high winds.

The reason behind Henry's proficiency in matrices was the layout of the of the East Alexandria soccer stadium, and specifically the A seating section. Henry's family had worked the A seating section for three generations. Every family member could tell you the smallest details of the section, such as which of the chairs were squeaky or where the best view was.

The A seating section had a remarkable resemblance of a rectangular matrix. It consisted of 25 rows of seats, and each row consisted of exactly 30 seats. As such, the seats were indexed by two numbers: a row number and column number. These were printed in bold letters on the ticket.

Henry's job at the stadium had two parts. First, before the game, he served as an usher and helped fans find their seats. Second, during the game, he served as a peanut vendor and made sure that every fan stayed sufficiently supplied with peanuts. Henry took his job quite seriously, and he had become very good at it.

As an usher, Henry excelled in randomly accessing matrix elements in order to guide people to their seats. "Row 3, Column 7? Right this way, sir!" Henry would start at the lower corner of the section and walk the patrons up to their seats. In this case, he first walked up to row 3 and then over to column 7.

As a peanut vendor, Henry became adept at traversing the matrix of seats while looking for hungry soccer fans. He would iterate over the entire matrix by walking past each seat in a row before moving down to the next row. Years of experience had taught Henry that for this particular stadium design it was much easier to move between seats in a row, rather than moving between rows in a column. Climbing over the chairs between rows turned out to be surprisingly difficult. Knowing whether it was easier to move between columns in a row or rows in a column was a very important consideration for a peanut vendor.

Henry became famous later in life when he published his domain expertise in a 5 volume series entitled "On Selling Peanuts and Traversing Stadium Seats". Despite becoming a canonical reference in the field, this work was best known for its bold introduction of a portable, steam-powered, peanut thrower. Henry was able to use the proceeds from these books to retire early and buy his own season tickets to the East Alexandria soccer team (row 1, column 9)!

## No comments:

## Post a Comment

Note: Only a member of this blog may post a comment.