Difference between revisions of "Working with Partially Filled Arrays"

From CompSciWiki
Jump to: navigation, search
Line 11: Line 11:
 
There are 3 types of partially filled arrays:
 
There are 3 types of partially filled arrays:
  
1. Linear Contiguous Block:
+
'''1. Linear Contiguous Block'''
  
2. Non-Linear Contiguous Block:
+
//placeholder for picture of linear contiguous block array
  
3. Non-Contiguous Block
+
The filled values in the array start at the first element, and additional element that's filled comes immediately
 +
after the previously filled element. However, the array is not completely full. This is the easiest type of partially filled array to deal with.
 +
 
 +
'''2. Non-Linear Contiguous Block'''
 +
 
 +
The non-linear contiguous block is very similar to the linear contiguous block, except that the contiguous block of filled array values does not start at the first element. However, the values still form a solid block of values in the array.
 +
 
 +
 
 +
'''3. Non-Contiguous Block'''
  
 
==Keeping Track of Array Elements==
 
==Keeping Track of Array Elements==

Revision as of 22:49, 4 December 2007

COMP 1010 Home > More With Arrays > Working with Partially Filled Arrays


Introduction

When working with arrays, you will come across situations where some values in an array do not have data. These arrays are said to be 'partially filled'. This section will show you why partially filled arrays occur, types of partially filled arrays, and how to handle partially filled arrays.

   

{{{Body}}}

Why Partially Filled Arrays Occur

Partially filled arrays occur because once an array size it set, the size of the array cannot be changed. Therefore, we generally pick an array size that is large enough to hold the potential number of values that need to be stored.

For example, if the average number of values that need to be stored is 20, but you could potentially have 40, then you need to make an array of size 40. However, this means that on average, half of the array will be empty.

Types of Partially Filled Arrays

There are 3 types of partially filled arrays:

1. Linear Contiguous Block

//placeholder for picture of linear contiguous block array

The filled values in the array start at the first element, and additional element that's filled comes immediately after the previously filled element. However, the array is not completely full. This is the easiest type of partially filled array to deal with.

2. Non-Linear Contiguous Block

The non-linear contiguous block is very similar to the linear contiguous block, except that the contiguous block of filled array values does not start at the first element. However, the values still form a solid block of values in the array.


3. Non-Contiguous Block

Keeping Track of Array Elements

code before the wicked box thang!


this pre tag is cool because it gives you a wicked box thing YOWZA~

more text after the wicked boxenz

Checking for Empty Array Values

wahooo!

Example.jpg