Re: Another question about multidimentional arrays

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"Victor Bazarov" <v.Abazarov@xxxxxxxxxxxx> wrote in message
news:g23m2g$nkl$1@xxxxxxxxxxxxxxxxxx
Ron Francis wrote:
I have wondered what the benefit is to using multidimensional arrays.

They represent the abstractions in your model correctly.

Isn't
int arr[10][10];
basically the same as
int arr[100];

The type is different, but the contents (and the memory they occupy) are
essentially the same.

Is the only benefit in how you visual the array in your mind in columns
and rows?

Mmm... It's all in the algorithms you use.

Is there any speed gain in using a single dimensional array?

No, and it's usually a rather huge loss when it comes to code clarity and
maintainability. The point of having the two dimensions is that your
algorithms are so much clearer when you allow the compiler to do the
actual resolving of the indices.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


Thanks Victor,
I must be a linear type of guy because I haven't had much use for them.
When I first learned about them I remember thinking that the syntax for
passing and deleting (from distant memory) was awkward.

While I'm here, I want to say that I read a lot of replies from you and
Ulrich and just want to say thanks for your generosity.
All the best.

Regards,
Ron Francis
www.RonaldFrancis.com



.



Relevant Pages

  • Re: random generator for a given period
    ... > that memory seems cheap without being so. ... The efficiency game it all about algorithms and rarely about polishing the code. ... Then you can sort on the random numbers with the array of indices passive. ... So what I'm looking for is a random numbers generator of a given period and with the range equal to the period. ...
    (sci.stat.math)
  • Re: Formal Semantics of the Java "new" Operator
    ... of mathematics by and large does not try to describe computations. ... Algorithms belong to computer science --- if pressed, ... "random access memory," which is essentially a big pool of "storage," ... which are typically some sort of integers. ...
    (comp.theory)
  • Re: teaching a child - console or GUI
    ... Implementing tricks to make a RDBMS compete with an in-mem solution is not ... only requires adding some memory to some old server or workstation and copying ... data + server .exe on it. ... > I really do believe that the key to speed is algorithms, ...
    (comp.lang.pascal.delphi.misc)
  • Re: Lifetime of flash memory
    ... CF wear-levelling algorithms: how good or bad is it? ... Well the map has to be stored in flash or other non volatile memory. ... It consists of a connector that exactly emulates an IDE drive connector ... software mounts the root file-system R/O with a ram-disk mounted ...
    (Linux-Kernel)
  • Re: about garbage collector
    ... Go through memory unmarking all objects. ... There is lots of research into faster and much more complicated algorithms. ... If you're interested, you could get a copy of Garbage Collection: Algorithms for Automatic Dynamic Memory Management, ...
    (comp.lang.java.programmer)