Problem 2
Determine whether each statement is true or false. If false, explain why. a) Values of primitive types may be stored directly in a Vector. b) A set can contain duplicate values. c) \(A\) Map can contain duplicate keys. d) \(A\) LinkedList can contain duplicate values. e) Collections is an interface. f) Iterators can remove elements. g) With hashing, as the load factor increases, the chance of collisions decreases. h) A PriorityQueue permits null elements.
Problem 3
Define each of the following terms: a) Collection b) Collections c) Comparator d) List e) load factor f) collision g) space-time trade-off in hashing h) HashMap
Problem 4
Explain briefly the operation of each of the following methods of class Vector: a) add b) insertElementat c) set d) remove e) removeAT 7 Elements f) removeElementat g) firstElement h) lastElement i) isEmpty j) contains k) indexof I) size \(\mathrm{m})\) capacity
Problem 5
Explain why inserting additional elements into a Vector object whose current size is less than its capacity is a relatively fast operation and why inserting additional elements into a Vector object whose current size is at capacity is a relatively slow operation.
Problem 6
By extending class Vector, Java's designers were able to create class Stack quickly. What are the negative aspects of this use of inheritance, particularly for class Stack?
Problem 7
Briefly answer the following questions: a) What is the primary difference between a Set and a Map? b) Can a two-dimensional array be passed to Arrays method asList? If yes, how would an individual element be accessed? c) What happens when you add a primitive type (e.g., double) value to a collection? d) Can you print all the elements in a collection without using an Iterator? If yes, how?
Problem 8
Explain briefly the operation of each of the following Iterator-related methods: a) iterator b) hasNext c) next
Problem 9
Explain briefly the operation of each of the following methods of class HashMap: a) put b) get c) isEmpty d) containskey e) keyset
Problem 10
Determine whether each of the following statements is true or false. If false, explain why. a) Elements in a Collection must be sorted in ascending order before a binarySearch may be performed. b) Method first gets the first element in a TreeSet. c) \(A\) List created with Arrays method asList is resizable. d) Class Arrays provides static method sort for sorting array elements.
Problem 13
Write a program that reads in a series of first names and stores them in a LinkedList. Do not store duplicate names. Allow the user to search for a first name.