Questions Chapter 2 Flashcards

1
Q

Inserting an item into an unordered array:

a. takes time proportional to the size of the array.
b. requires multiple comparisons
c. requires shifting other items to make room
d. takes the same time no matter how many items there are

A

takes the same time no matter how many items are there

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

True or False: When you delete an item from an unordered array, in most cases you shift other items to fill in the gap.

A

True

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

In an unordered array, allowing duplicates:

a. increases times for all operations
b. increases search times in some situations
c. always increases insertion times
d. sometimes decreases insertion times

A

increases search times in some situations

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

True or False: In an unordered array, it’s generally faster to find out an item is not in the array than to find out it is.

A

False

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

Creating an array in Java requires using the keyword _______.

A

new

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

If class A is going to use class B for something, then:

a. class A’s methods should be easy to understand
b. it’s preferable if class B communicates with the program’s user
c. the more complex operations should be placed in class A
d. the more work that class B can do, the better.

A

d. the more work that class B can do, the better.

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

When class A is using class B for something, the methods and fields class A can access in class B are called class B’s ____________.

A

interface.

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

Ordered arrays, compared with unordered arrays, are:

a. much quicker at deletion
b. quicker at insertion
c. quicker to create
d. quicker at searching

A

d. quicker at searching

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

A logarithm is the inverse of ________ _______ _________.

A

raising to a power.

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

The base 10 logarithm of 1,000 is _________.

A

3

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

The maximum number of elements that must be examined to complete a binary search in an array of 200 elements is:

a. 200
b. 8
c. 1
d. 13

A

8

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

The base 2 logarithm of 64 is ____.

A

6

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

True or False: The base 2 logarithm of 100 is 2.

A

False

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

Big O notation tells:

a. how the speed of an algorithm relates to the number of items
b. the running time of an algorithm for a given size data structure
c. the running time of an algorithm for a given number of items
d. how the size of a data structure relates to the number of items

A

a how the speed of an algorithm relates to the number of items

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

O(1) means a process operates in _________ time.

A

constant

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

Either variables of primitive types or ________ can be placed in an array.

A

objects

17
Q

__________ arrays offer fast insertion, but slow searching and deletion.

A

Unordered

18
Q

A _______ ________ is composed of the methods (and occasionally fields that the class user can access.

A

class interface

19
Q

A binary search can be applied to an ________ array.

A

ordered

20
Q

The logarithm to the base B of a number A is (roughly) the number of times you can divide A by B before the result is less than ______.

A

1

21
Q

Binary searches require time proportional to the logarithm of the number of _______.

A

items

22
Q

An algorithm that runs in _____ time is best, _____ time is good, _____ time is fair, and ______ is pretty bad.

A

O(1) is best, O(log N) is good, O(N) is fair, and O(N^2) is pretty bad.