# Algorithm代写 | 作业java | oop代做 – Sample

### Sample

Algorithm代写 | 作业java | oop代做 – 这是一个oop面向对象设计的practice, 考察oop的理解, 涵盖了Algorithm/java/oop等方面

a) TRUE FALSE If you insert an already sorted sequence into a TreeMap (i.e. "a" "b" "c" "d" and so on), you could generate a TreeMap whose Tree is a one armed degenerate tree – which could degrade the performance of the TreeMap to be linear instead of logarithmic.

b) TRUE FALSE If you knew the exact Algorithm being used by a HashMap, it might be possible to feed it a specific sequence of values that could significantly degrade the performance of the HashMap.

c) TRUE FALSE A TreeMap uses space in a more "incremental" manner than a HashMap

d) TRUE FALSE A LinkedList is "closer in structure" to a TreeSet than it is to a HashSet.

e) TRUE FALSE If you are storing small data sets and want to keep things sorted, you should use HashSet instead of TreeSet.

f) TRUE FALSE If you knew that your hashcode algorithm was about as close to perfect as is possible, then it would make sense to have a very HIGH load factor set for your hashmap.

g) TRUE FALSE Both the TreeSet and the HashSet have to resize (generally, double) their capacity if the number of values stored exceeds the initial amount of space allocated.

h) TRUE FALSE If you want to print all the values from one of our List/Tree/Map containers, you MUST use the iterator if you want to guarantee you do not miss any values or corrupt the state of the container.

i) TRUE FALSE If you leave the <>’s off of your container declaration, your program will generate a runtime exception.

k) TRUE FALSE If you set your load factor very LOW then you may have to RESIZE your HashMap more often that you would with a HIGH load factor.

l) TRUE FALSE If you are doing an insertion onto the front/beginning of the sequence, ArrayList inserts at front faster than LinkedList

m)TRUE FALSE A TreeSet uses more space to store a single entry than does a LinkedList to store a single entry.

n) TRUE FALSE The uniformity (distribution) of the hashcode function is probably the most important factor in a TreeSet’s performance.

o) TRUE FALSE You can feed a plain array of String into the constructor of a TreeSet. i.e. TreeSet( plainarrOfPlainStrings )

p) TRUE FALSE You can feed an ArrayList of String into the constructor of a TreeSet. i.e. TreeSet( ArrayListOfStrings )

q) TRUE FALSE You can feed a Set of String into the constructor of a HashMap. i.e. HashMap( someSetOfStrings )

r) TRUE FALSE The statement at the end of Problem #2 is accurate and correct. i.e. YES OR NO, is the code written using loops to add the tokens to the hash, less efficient than the version that feeds the array of tokens to the constructor?

s) TRUE FALSE Iterators should only be used when you are modifying the contents of a container

t) TRUE FALSE A good hashcode algorithm uses all the bytes/chars in a String to determine the value

#### #2 10pts. Look at the 2 programs HSDemo1 and HSDemo

Note that HSDemo2 uses loops to add the tokens into the set while HSDemo1 does not need loops because it converts the tokens array into a list.

###### Consider this statement for Problem#2 : "The demo that uses a l oop to put the tokens into the set
``````will have a higher complexity big O for that operation, than the demo that lets  java convert the array to
a list and initializes the Set directly in one line of code."
``````