Chapter 7 Flashcards
Anonymous array
An array created without an explicit reference.
array
A data structure for storing a collection of data of the same type.
array initializer
A short hand notation to create and initialize an array.
binary search
An efficient method to search a key in an array. Binary search first compares the key with the element in the middle of the array and reduces the search range by half. For binary search to work, the array must be pre-sorted.
garbage collection
A JVM feature that automatically detects and reclaims the space occupied by unreferenced objects.
index
An integer value used to specify the position of an element in the array. The array index is an int value starting with 0 for the first element, 1 for the second, and so on.
indexed variable
A variable that is represented using an array reference along with an index to refer to an individual element in the array.
linear search
A method to search an element array. Linear search compares the key with the element in the array sequentially.
off-by-one error
Programmers often mistakenly reference the first element in the array with index 1, but it should be 0. This is called the off-by-one error.
postcondition
Used to describe the properties of a method. Postcondition are the things that are true after a method is called.
precondition
Used to describe the properties of a method. Precondition are the things that are true before a method is called.
selection sort
An approach to sort an array. It finds the largest number in the list and places it last. It then finds the largest number remaining and places it next to last, and so on until the list contains only a single number.