zuai-logo
zuai-logo
  1. AP Computer Science A
FlashcardFlashcardStudy GuideStudy GuideQuestion BankQuestion BankGlossaryGlossary

Glossary

0

0-indexed language

Criticality: 3

A programming language where the first element in an array or sequence is at index 0, rather than 1.

Example:

Java is a 0-indexed language, meaning if you have an array of 5 elements, their valid indices range from 0 to 4.

1

1D arrays

Criticality: 2

A linear data structure that stores a sequence of elements of the same type in contiguous memory locations.

Example:

A shopping list can be stored in a String[] like String[] shoppingList = {"milk", "eggs", "bread"}, where each item is accessed by a single index.

2

2D array

Criticality: 3

A data structure that stores elements in a grid-like format, organized by rows and columns. It's essentially an array of arrays.

Example:

To store a tic-tac-toe board, you might use a char[][] to represent the 3x3 grid, like char[][] board = {{'X', 'O', ' '}, {' ', 'X', 'O'}, {'O', ' ', 'X'}} where each inner array is a row.

A

ArrayIndexOutOfBoundsException

Criticality: 3

A runtime error that occurs when a program attempts to access an array element using an index that is outside the valid range of indices for that array.

Example:

If you have an array int[] arr = new int[5]; and you try to access arr[5], you will get an ArrayIndexOutOfBoundsException because the valid indices are 0 through 4.

D

Double-index notation

Criticality: 3

The method of accessing elements in a 2D array using two bracketed numbers: the first for the row index and the second for the column index.

Example:

To get the element in the second row and third column of a 2D array named data, you would use data[1][2] using double-index notation.

G

Grid, table, or matrix

Criticality: 2

Visual metaphors used to represent rectangular 2D arrays, emphasizing their organization into rows and columns, similar to a spreadsheet or a mathematical matrix.

Example:

A chessboard can be easily visualized as an 8x8 grid or matrix of squares, which directly maps to a char[8][8] array in Java.

I

Indices

Criticality: 3

Numerical positions used to access individual elements within an array, starting from zero.

Example:

In the array int[] nums = {10, 20, 30};, the value 20 is at index 1.

N

Nested array

Criticality: 2

The conceptual representation of a 2D array in memory, where the 'outer' array contains references to 'inner' arrays, each holding the actual data.

Example:

When you declare int[][] matrix = new int[2][3];, Java creates an outer array of 2 elements, and each of those elements points to a separate inner array of 3 integers, forming a nested array structure.

O

Outer array

Criticality: 2

In a 2D array's memory representation, this is the primary array that holds references to the individual row arrays.

Example:

For int[][] scores = new int[3][5];, the scores variable itself refers to the outer array, which contains three references, one for each row of scores.

R

Rectangular arrays

Criticality: 3

A type of 2D array where all inner arrays (rows) have the exact same number of elements (columns), forming a perfect rectangle or grid.

Example:

A spreadsheet with 5 rows and 3 columns of numbers would be a rectangular array, as every row has exactly 3 entries.

l

length (for arrays)

Criticality: 3

A public final field of an array that indicates the number of elements it can hold. For a 2D array, `arrayName.length` gives the number of rows, and `arrayName[0].length` gives the number of columns (for rectangular arrays).

Example:

If you have String[] names = {"Alice", "Bob"};, names.length would be 2. For int[][] grid = new int[4][5];, grid.length is 4 (rows) and grid[0].length is 5 (columns), helping you iterate through the entire length of the array.