Questions Chapter 2 Flashcards
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
takes the same time no matter how many items are there
True or False: When you delete an item from an unordered array, in most cases you shift other items to fill in the gap.
True
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
increases search times in some situations
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.
False
Creating an array in Java requires using the keyword _______.
new
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.
d. the more work that class B can do, the better.
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 ____________.
interface.
Ordered arrays, compared with unordered arrays, are:
a. much quicker at deletion
b. quicker at insertion
c. quicker to create
d. quicker at searching
d. quicker at searching
A logarithm is the inverse of ________ _______ _________.
raising to a power.
The base 10 logarithm of 1,000 is _________.
3
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
8
The base 2 logarithm of 64 is ____.
6
True or False: The base 2 logarithm of 100 is 2.
False
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 how the speed of an algorithm relates to the number of items
O(1) means a process operates in _________ time.
constant