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

Glossary

A

Array Index

Criticality: 3

A numerical position of an element within an array, where the first element is at index 0 and the last element is at index array.length - 1.

Example:

In an array String[] fruits = {"apple", "banana", "cherry"};, "banana" is located at array index 1.

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 (0 to array.length - 1).

Example:

Trying to access myArray[10] when myArray only has 5 elements will immediately cause an ArrayIndexOutOfBoundsException.

D

Different End Index

Criticality: 2

A technique in limited traversal where array iteration concludes before array.length - 1, allowing processing to stop at a specific point within the array.

Example:

To analyze only the first n entries of a log file, you would use a different end index in your loop condition.

Different Start Index

Criticality: 2

A technique in limited traversal where array iteration begins from an index other than 0, allowing processing to start at a specific point within the array.

Example:

If the first element of an array is a header, you might use a different start index (e.g., i = 1) to process only the actual data.

F

For loop

Criticality: 3

A control flow statement commonly used for array traversal, allowing code to be executed repeatedly for a fixed number of iterations based on an initialization, condition, and increment/decrement.

Example:

A for loop for (int i = 0; i < scores.length; i++) is ideal for iterating through an array of student scores to find the average.

Forward Traversal

Criticality: 3

Iterating through an array from its beginning (index 0) to its end (array.length - 1), typically by incrementing the loop index.

Example:

Printing all elements of an array in their original sequence requires forward traversal.

L

Limited Traversal

Criticality: 2

Iterating through only a specific portion or subsection of an array, rather than processing all its elements.

Example:

To find the maximum value only within the first five elements of a large dataset, you'd perform a limited traversal.

R

Reverse Traversal

Criticality: 2

Iterating through an array from its end (array.length - 1) to its beginning (index 0), typically by decrementing the loop index.

Example:

If you need to process a list of recent messages from the newest to the oldest, you'd use reverse traversal.

S

Subsection Traversal

Criticality: 2

A form of limited traversal that processes a specific range of elements within an array by defining both a custom start and end index.

Example:

To update only the middle section of a game board represented by an array, you would perform a subsection traversal.

T

Traversing

Criticality: 3

The process of accessing every value or element within an array, typically accomplished by iterating through it using a loop.

Example:

To calculate the sum of all elements in an array, you would traverse it, adding each element to a running total.

W

While loop

Criticality: 2

A control flow statement that repeatedly executes a block of code as long as a given boolean condition remains true, which can also be used for array traversal.

Example:

A while loop could be used to find the first negative number in an array by continuing as long as the current element is non-negative.

a

array.length

Criticality: 3

A property of an array that returns the total number of elements it can hold, often used to define the upper bound of a traversal loop.

Example:

If int[] scores = new int[10];, then scores.*length* would be 10, indicating it can store ten integers.