English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

6 answers

lol. Good question ive kinda been stuck here for a while.

I think the answer is that it does not make it more efficient, but more organzied.

If you had a multiplayer game, you had to keep track of the variables "Player1Score", "Player2Score", and "Player3Score".

Instead of calling one of those variables each time you wish to operate with it, you could just use PlayerScore(1) or PlayerScore[1] & PlayerScore(2) or PlayerScore[3]

-- *Syntax will vary by language* --

So it cuts the amount of vaiables you need to maintain down. It may save memory (idk) or increase speed... something technical like that, im not sure. But in general, it makes variables more organzied, cuts down on spelling differences between variables like "Player1Score" & "player2score".

2006-11-21 10:40:03 · answer #1 · answered by agent69akasexy 2 · 0 1

Arrays make things more efficient because the computer can quickly jump to a specific location in memory based on the index and the type of array it is. That is why arrays are the same type.

For example... when you create an array of 100 integers, the OS knows to make 100 spots each 4 bytes long. So it allocates 400 bytes.

Now when you request lets say number 20 it can quickly go 4 X 20 and jump to the 80th byte in that contiguous piece of allocated memory and fetch the value stored there.

Plus since an array is completely held in memory, the OS does not have to go anywhere but RAM to fetch values. To take this one step further, if this memory is what is known as "L2" cache, then it is even faster to access because it is right on the same chip as the actual CPU.

Being that arrays are the same type, faster to look up, stored in RAM and contiguous, it makes arrays much more efficient.

Hope this answers your question.

2006-11-21 11:08:11 · answer #2 · answered by Martyr2 7 · 0 0

It depends on your situation. Sometimes arrays aren't the most efficient. What programming language are you using? .NET 2.0 there is a bunch of different solutions to make Arrays more efficient like List Items.

Arrays have to have a predetermined number when instantiating. ListItems don't. You can add, remove, add, remove, sort, change, etc. It all depends on what you need them for.

2006-11-21 12:11:02 · answer #3 · answered by comn8u 4 · 0 0

with array you can make many variable with a type(object ,reference or value) and traverse it by loop and use one to one part of an array. in object oriented programing such c# , array make software more easy to develop.

2006-11-21 19:31:21 · answer #4 · answered by dxsamran31 2 · 0 0

You can hold large number of like types together under a single name. This allows you to pass it to functions easily. Also, you can perform fast operations to flip through the array and perform set operations (minimum, maximum, mean, std dev, etc)

2006-11-21 11:09:46 · answer #5 · answered by WickedSmaht 3 · 0 1

I thing because 1 variable can holder more than 1 #'s etc

2006-11-21 10:34:20 · answer #6 · answered by Best Helper 4 · 0 0

fedest.com, questions and answers