1. Give a description, in pseudocode, for implementing the retainAll method for the set ADT, using only the other fundamental methods of the set.2. If we let n denote the size of set S, and m denote...
Popular Questions - Uncategorized
The java.util.HashMap class uses separate chaining, but without any explicit secondary structures. The table is an array of entries, and each entry has an additional next field that can reference...
1. If we let n denote the size of set S, and m denote the size of set T, what would be the running time of the operation S.addAll(T), as implemented on page 446, if both sets were implemented using...
For an ideal compression function, the capacity of the bucket array for a hash table should be a prime number. Therefore, we consider the problem of locating a prime number in a range [M,2M]....
Consider the goal of adding entry (k,v) to a map only if there does not yet exist some other entry with key k. For a map M (without null values), this might be accomplished as follows.While this...
1. Explain how the k largest elements from an unordered collection of size n can be found in time O(n+k log n) using a maximum-oriented heap.2. Explain how the k largest elements from an unordered...
Recent Comments