Ch. 6 Flashcards

(49 cards)

1
Q

What is the purpose of an array?

A

Help us organize large amounts of data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What type of thing is an array?

A

An object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What must be the same when working with 2 different arrays?

A

Their datatypes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is an array?

A

An ordered list of values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Where does array indexing start?

A

0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you find the value of an array index?

A

name[location]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you overwrite an array value?

A

name[location]=whatever

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is an array element?

A

A value held in an array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is necessary for all array elements?

A

They are the same datatype

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Are there any datatypes an array doesn’t support?

A

No

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you define an array?

A

int[]name=new int[length]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What should you always do with an array?

A

Make it a bit larger than needed just in case

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What must we careful of when pulling array elements?

A

The index is in-bounds

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What happens if we call an out-of-bounds index?

A

An exception is thrown

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the max index?

A

1 less than the number of values held in the array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you find the length of an array?

A

name.length (just that)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is name.length of an array?

A

The public length constant

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is an initializer list?

A

Making the array and defining its elements all in one shot.

int[]name={1,2,3,4,5]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is necessary for an initializer list?

A

The data is in braces and separated by commas

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What determines the array length in an initializer list?

A

The number of elements initially input

21
Q

Can an array be a parameter?

A

Yes, it can be fed into a method

22
Q

What happens if you change an array element in a method?

A

They are all changed

23
Q

What is a command line argument?

A

Doing something with java in DOS. This can make life easier if you do it in a batch file

24
Q

What is necessary when you do a sting array?

A

Each thing is added individually

25
What is linear searching?
Searching each element of an array in succession for ordered data
26
What is binary searching?
A search in an array that is ordered
27
How does the search order work in a binary search?
Like our number guessing game, where it starts in the middle and works its way up or down
28
What is array sorting?
Putting the elements in a specific order
29
What is a user capable of defining in array sorting?
How the sorting is done.. ie by comparison of a few things
30
What do list algorithms do for sorting?
Make the process as efficient as possible
31
How many statements are needed to exchange variables and why?
3, so no data is destroyed. temp=swap1; swap1=swap2; swap2=temp;
32
What is used when we are defining our own sorting?
We use the Comparable interface and define compareTo
33
What is big-oh notation?
Looking at how efficient something is (see chart in notes)
34
What does Big-Oh predict?
The absolute longest a piece of code should take to run
35
How is data storage made more efficient?
Spreading it out over multiple locations
36
What is hashing?
Makes data storage faster and more efficient by not storing it all in the same location
37
What is hash code?
The function that tells the array where to store the data
38
How is hashing like layering?
Filling up a spread of locations in memory with array elemnts
39
What is a two dimensional array?
Kind of like a table of values where we specify rows and columns
40
What is a one dimensional array?
Where we just list data
41
How do you specify a two-dimensional array?
int [][] name= new int [rows][columns]
42
How do you index a two-dimensional array?
variable=name[row][column]
43
What is ArrayList?
A method that creates a special type of array, has a list of values and treats them like indexes
44
What is good and bad about ArrayList?
It can be resized, but it takes up more memory
45
What happens if you add/remove something in ArrayList?
The indexes are updated. Ie if something is removed, the indexes of everything behind it are pushed up one
46
Do datatypes need to be consistent in ArrayList?
No
47
How are arrays good for graphics data?
It is stored in arrays
48
What is selection sorting?
Finding the lowest number in the list and swaping it into the first element
49
What is insertion sorting?
Sorting by the first 2 then 3 then 4 and so on so that the smallest comes first.