Term
|
Definition
double[ ] sales = new double[20]; //Array has 20 items
the first sales array element is sales[0], and
the last sales element is sales[19].
THE NUMBER IN THE [ ] IS THE ELEMENT POSITION. NOT THE VALUE. |
|
|
Term
Assigning and Printing Array Values |
|
Definition
sales[0] = 2100.00; // The first array element assigned 2100.00
WriteLine(sales[19]); // Prints the 20th array element |
|
|
Term
|
Definition
|
|
Term
Using Loops on Each Element |
|
Definition
|
|
Term
Using the Length Property in an Array |
|
Definition
|
|
Term
Searching Arrays Using Loops |
|
Definition
|
|
Term
|
Definition
Parallel arrays are a common programming technique where you use multiple arrays to store related data. Each array holds a specific type of data, and elements at the same index in each array are related to each other.
Ex.) // Parallel arrays: names, ages, and grades
string[] names = { "Alice", "Bob", "Charlie", "Diana" };
int[] ages = { 20, 21, 19, 22 };
char[] grades = { 'A', 'B', 'A', 'C' };
|
|
|
Term
|
Definition
BinarySearch( ) method - MUST BE ARRANGED IN ASCENDING ORDER TO WORK. A sorted list of objects is split in half repeatedly as the search gets closer and closer to a match. Starts with Is it less than 50? Less than 25? Less than 12? Etc.
Array.Sort( ) method - arranges array items in ascending order. Often used before BinarySearch( ).
Array.Reverse( ) method - The Reverse() method does not sort array elements; it only rearranges their values to the opposite order. |
|
|
Term
|
Definition
dataType[,] arrayName = new dataType[rows, columns];
double[,] sales = new double[3,3];
{ 1, 2, 3 }, // Row 0
{ 4, 5, 6 }, // Row 1
{ 7, 8, 9 } // Row 2
sales [0, 2] refers to the element in Row 0, Column 2; which in this case is the value "3."
|
|
|
Term
|
Definition
Similar to two-dimensional arrays in the way that it is written:
Ex.)
dataType[, , ] arrayName = new dataType[dimension1, dimension2, dimension3];
int[,,] threeDArray = new int[3, 3, 3];
|
|
|