Computer Science 1050-Ch. 6 Notes (Arrays)

array

data structure consisting of related data items of the same type

static

Arrays and structures are ____ entities in that they remain the same size throughout program execution.

position number

To refer to a particular location or element in the array, we specify the name of the array and the ____ of the particular element in the array.

zero

The first index value of the array is ____. 12 elements go from 0 to 11.

outside of the bounds

If you try and get a number OUTSIDE the array, you will get a segmentation fault. You are not allowed to go in memory __________.

zeroth element

The first element in every array is the ______.

subscript (index)

The position number contained within square brackets is more formally called a ______ ( ____ )

type of each element and number of elements

You specify the _____ and _____ required by each array so that the computer may reserve the appropriate amount of memory.
Ex: int array[12]

initializers

The elements of an array can also be initialized when the array is defined by following the definition with an equals sign and braces, {}, containing a comma-separated list of ______.

zero

If there are fewer initializers than elements in the array, the remaining elements are initialized to ______.

are NOT

arrays _____ automatically initialized to zero. You must at least initialize the first element to zero for the remaining elements to be automatically zeroed.

the number of elements in the initializer list

If the array size is omitted from a definition with an initializer list, the number of elements in the array will be ______. Ex: int n[] = {1, 2, 3, 4, 5} would create a five-element array

syntax error

The array definition int n[5] = {1, 2, 3, 4, 5, 6} causes a _____ because there are 6 initializers and only five array elements.

capital letters

Tip: Use _____ in #define variable, easier to read.

symbolic constant

#define SIZE 10 defines a _____ SIZE whose value is 10.

scalability

ability to modify a system. Using symbolic constants to specify array sizes makes programs more scalable.

multiple-subscripted arrays

A common use of ______ is to represent tables of values consisting of information arranged in rows and columns.

row

first subscript identifies the element's _____

column

second subscript identifies the element's _____

m-by-n array

In general, an array with m rows and n columns is called an _______.

\0

null character

null operator

All strings in C end with ______.

characters + null character

a character array (string) contains number of ________

string variables

______ do NOT require & in scanf function

%s

string conversion specifier

static

A _____ local variable exists for the duration of the program, but is visible only in the function body.

name of the array without any brackets

To pass an array argument to a function, specify the _______

hexidecimal

(base 16) 0-9 and A-F

by reference

C automatically passes arrays to functions ______--the called functions can modify the element values in the callers' original arrays.

%p

conversion specifier normally outputs addresses as hexidecimal numbers

by value

Although entire arrays are passed by reference, individual array elements are passed ____ exactly as simple variables are.

const

prevents modification of array values in a function. The array elements become constant in the function body, and any attempt to modify an element of the array in the function body results in a compile-time error.

linear search

1 Billion, _____ on average 500,000,000 searches

binary search

1 Billion, _____ on average 30 searches.

bubble sort

the smaller values gradually "bubble" their way upward to the top of the array like air bubbles rising in water, while the larger values sink to the bottom of the array.

only one position

Because of the way the successive comparisons are made, a large value may move down the array many positions on a single pass, but a small value may move up _______.

swap

hold = a[i];
a[i] = a[i+1];
a[i+1] = hold;

key value

To determine whether an array contains a value that matches a certain ______.

searching

The process of finding a particular element of an array is called _____.

linear search

The _____ method works well for small or unsorted arrays.

binary search

If the array is sorted, the high-speed ______ technique can be used.

maximum comparisons

The _____ for any array can be determined by finding the first power of 2 greater than the number of array elements.