Ch. 6 Flashcards Preview

Comp Sci > Ch. 6 > Flashcards

Flashcards in Ch. 6 Deck (49)
Loading flashcards...
1

What is the purpose of an array?

Help us organize large amounts of data

2

What type of thing is an array?

An object

3

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

Their datatypes

4

What is an array?

An ordered list of values

5

Where does array indexing start?

0

6

How do you find the value of an array index?

name[location]

7

How do you overwrite an array value?

name[location]=whatever

8

What is an array element?

A value held in an array

9

What is necessary for all array elements?

They are the same datatype

10

Are there any datatypes an array doesn't support?

No

11

How do you define an array?

int[]name=new int[length]

12

What should you always do with an array?

Make it a bit larger than needed just in case

13

What must we careful of when pulling array elements?

The index is in-bounds

14

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

An exception is thrown

15

What is the max index?

1 less than the number of values held in the array

16

How do you find the length of an array?

name.length (just that)

17

What is name.length of an array?

The public length constant

18

What is an initializer list?

Making the array and defining its elements all in one shot.
int[]name={1,2,3,4,5]

19

What is necessary for an initializer list?

The data is in braces and separated by commas

20

What determines the array length in an initializer list?

The number of elements initially input

21

Can an array be a parameter?

Yes, it can be fed into a method

22

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

They are all changed

23

What is a command line argument?

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

24

What is necessary when you do a sting array?

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.