0

1

2

3

4

5

6

7

Bob

Fred

Sally

Barny

Beth

Susan

John

George

 

Above is an array of size 8. It has 8 elements within it. It is a data structure where you can put items into the array at what ever position you want to. In order to access the array you need two bits of information. The name of the array and also the position you want to add too. When you first create an array, even before you put any data into it, you must specify the size of the array. In Java this would look something like this -

String arrayOfNames[] = new String[8];

If I wanted to add 10 names to my array I would not be able to do this. I would be faced with the three scenarios looked at in the overflowing bucket analogy.

Static data structures are not suitable if you do not know up front how much data you are going to store. Also you can not just create a huge array because when the array is created it puts aside the maximum amount of memory it will need. It does this even if you do not use the array to put in any data at all!

Advantages

  • Very easy to create and set up. Supported by most computer languages
  • Quick access and allows random access

Disadvantages

  • Set size so only suitable when you know exactly how much data you are going to store.
  • Can be wasteful of memory if you are only going to use half the array.