2 Dimensions are Better than 1, right?

Many problems deal with more than single dimensional data.  At the risk of beating the grade example to pieces, think about the idea of a class having 20 students and 4 exam grades for a semester.  Would it be possible to model this scenario with a 1D array?  Sure, absolutely.  Would it be fun?  Very unlikely.  Another example that you work with every day is graphics.  A picture or image, particularly one that displays on your screen, is nothing more than a 2D array of pixels.  If you think about each of those pixels having multiple values associated with it (one for red, one for blue, and one for green, for example), the the data model becomes 3D.  Many languages allow the programmer to model data with more than 1 dimension.  In C++, it is even easier to declare a multidimensional array than it is in Java.

Multidimensional arrays are covered in Overland Section 6.2.4, so you may have read about them already.  If so, fantastic.  If not, go now and read.  Here are a couple videos that would be helpful as well:  C++ Tutorial 14: 2D Arrays (make sure to pay attention to the end of the video that talks about “Reality of a Multidimensional Array” that starts about minute 17.   This Vimeo video is a short one I made related to passing 2D arrays to functions.

Speak Your Mind

*

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.