SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 313 Weeks Ago, 5 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 11 Dec 2017 My Price 7.00

HashSet that has a linear running time to find the elements

I need to use a HashSet that has a linear running time to find the elements that are common in all lists. For example, the following collection of lists of integers:

A1=[ 3 4 9 8 12 15 7 13]

A2=[ 15 24 50 12 3 9 3 ]

A3=[ 78 9 65 24 13 9 3 12]

A4=[ 15 78 14 3 2 9 44 12 ]

Then the common elements in this collection would be: [ 3 9 12] 

 

With the class CommonElements, I need to encapsulate the algorithm within a method called findCommonElements, that has the following signature:

  1. public static<T> List<T> findCommonElements(List<List<T>> collections){ 

The input argument to this method is a nested list (i.e., a list of list). The value returned by your method is a list of common elements. The algorithm for this method must use a HashSet and should have an average running time of O(nk) where n is the maximum number of elements in each list and K is the number of lists in the collection.

Attention: May NOT use the retainAll method in java.utilHashSet. 

 

This is the main method:

public static void main(String[] args)

{

List<List<Integer>>collections =new ArrayList<List<Integer>>(); collections.add(0,

new ArrayList<Integer>(Arrays.asList(3, 4, 9, 8, 12, 15, 7, 13)));

collections.add(1,

new ArrayList<Integer>(Arrays.asList(15,24,50,12,3,9)));

collections.add(2,

new ArrayList<Integer>(Arrays.asList(78,65,24,13,9,3,12)));

collections.add(3, new ArrayList<Integer>(Arrays.asList(15,78,14,3,2,9,44,12)));

List<Integer> result =findCommonElements(collections); } 

 

 

I need the following:

  1. CommonElements.java file (This should contain the findCommonElements method, as stated above)
  2. A document containing two things:
  3. A table that shows test cases. This table should have three columns:
  4. The collection of lists used for testing
  5. The expected list of common elements
  6. The return list of common elements by the program
  7. Briefly describe the algorithm and determine the time efficiency of it. Don’t just say, for example, that my algorithm is O(kn) (We already know this) but explain how you got that time efficiency.

Answers

(5)
Status NEW Posted 11 Dec 2017 12:12 PM My Price 7.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)