Ch. 6 Flashcards

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
Q

What is linear searching?

A

Searching each element of an array in succession for ordered data

26
Q

What is binary searching?

A

A search in an array that is ordered

27
Q

How does the search order work in a binary search?

A

Like our number guessing game, where it starts in the middle and works its way up or down

28
Q

What is array sorting?

A

Putting the elements in a specific order

29
Q

What is a user capable of defining in array sorting?

A

How the sorting is done.. ie by comparison of a few things

30
Q

What do list algorithms do for sorting?

A

Make the process as efficient as possible

31
Q

How many statements are needed to exchange variables and why?

A

3, so no data is destroyed.
temp=swap1;
swap1=swap2;
swap2=temp;

32
Q

What is used when we are defining our own sorting?

A

We use the Comparable interface and define compareTo

33
Q

What is big-oh notation?

A

Looking at how efficient something is (see chart in notes)

34
Q

What does Big-Oh predict?

A

The absolute longest a piece of code should take to run

35
Q

How is data storage made more efficient?

A

Spreading it out over multiple locations

36
Q

What is hashing?

A

Makes data storage faster and more efficient by not storing it all in the same location

37
Q

What is hash code?

A

The function that tells the array where to store the data

38
Q

How is hashing like layering?

A

Filling up a spread of locations in memory with array elemnts

39
Q

What is a two dimensional array?

A

Kind of like a table of values where we specify rows and columns

40
Q

What is a one dimensional array?

A

Where we just list data

41
Q

How do you specify a two-dimensional array?

A

int [][] name= new int [rows][columns]

42
Q

How do you index a two-dimensional array?

A

variable=name[row][column]

43
Q

What is ArrayList?

A

A method that creates a special type of array, has a list of values and treats them like indexes

44
Q

What is good and bad about ArrayList?

A

It can be resized, but it takes up more memory

45
Q

What happens if you add/remove something in ArrayList?

A

The indexes are updated. Ie if something is removed, the indexes of everything behind it are pushed up one

46
Q

Do datatypes need to be consistent in ArrayList?

A

No

47
Q

How are arrays good for graphics data?

A

It is stored in arrays

48
Q

What is selection sorting?

A

Finding the lowest number in the list and swaping it into the first element

49
Q

What is insertion sorting?

A

Sorting by the first 2 then 3 then 4 and so on so that the smallest comes first.