Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First observation - using a HashMap to represent your contacts smells of <a href="https://stackoverflow.com/questions/3725703/how-to-store-more-than-one-string-in-a-map/3725728#3725728">"object denial"</a>. </p> <p>You need to design and implement a Contact class to represent a contact. Without this class, your task is a whole bunch harder than it needs to be.</p> <p>The class needs getters for all of the contact key fields, and it needs to implement equals, hashcode and Comparable based on the key fields. Getters (and optionally setters) are also needed for non-key fields.</p> <p>With that, the merging process becomes (pseudo-code):</p> <pre><code>// If you haven't already done so convert the master list of HashMaps to a list of Contact objects and sort it. create an empty "new master" list for each list of contact HashMaps: convert the list of HashMaps to a merge list of Contact objects sort the merge list iterate the sorted master and merge lists in parallel: if a master Contact matches a merge Contact: merge the two Contacts and add to the new master list advance both iterators if a master Contact has no corresponding merge Contact: copy the master Contact to the new master list advance the master iterator. if a merge Contact has no corresponding master Contact: add the merge Contact to the new master list. advance the merge iterator </code></pre> <p>The performance characteristics of the various phases should be:</p> <ul> <li>Conversion of N HashMaps to Contact objects - <code>O(N)</code>.</li> <li>Creation of list of N Contacts - <code>O(N)</code></li> <li>Sort list of N Contacts - <code>O(NlogN)</code></li> <li>Merging of 2 sorted lists - <code>O(M + N)</code>.</li> </ul> <p>The overall performance should be better than <code>O(NlogN)</code> where N is the total number of master and merge Customer objects. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload