UNION HINTS - JAVA /* . . . . . . . . . .B E L O W A R E T H E M E T H O D S Y O U M U S T F I L L I N . . . . . . . . /* THE UNION METHOD 1) dimension an array (call it unionResult ) that is just big enough to handle the largest possible set for this operation. 2) copy all elements from set1 into unionResult. Then copy in those elements from set2 into unionResult that are NOT contained in unionResult 3) before returning the array, downsize it to the exact size as the number of elements in it. 4) There is no count to pass around so the length must be equal to the actual count. */ static String[] union( String[] set1, String[] set2 ) { String[] unionResult = new String[ (length of array to handle largest possible set) ]; int unionCount = 0; copy ALL the elements from set1 into the unionResult ( update count as you go ) HINT: use an enhanced for loop to visit each element in set1 for ( String elementFromSet1 : set1 ) tack it onto the unionResult **remember to use your unionCount++ // ONLY ADD ELEMENTS FROM SET#2 IF NOT ALREADY IN RESULT for ( String elementFromSet2 : set2 ) { if ( ! contains( unionResult, elementFromSet2 ) ) tack it onto the unionResult **remember to use your unionCount++ } downSize the unionResult array return the unionResult reference **HINT you could do both steps all in one } boolean contains( set, element ) { for every setElem in set if ( setElem matches equality with incoming single element ) ret T if you make it out of the loop then you never found a match so return F }