Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help filling in the code with JAVA, ONLY edit the parts between the bolded. import java.util.TreeSet; import java.util.Set; /** Illustrates basic operations of a

Need help filling in the code with JAVA, ONLY edit the parts between the bolded.

import java.util.TreeSet;

import java.util.Set;

/**

Illustrates basic operations of a set.

Your job is to write the static method for set intersection.

*/

public class SetTester1

{

public static void main(String[] args)

{

Set set1 = new TreeSet() ;

set1.add("A") ;

set1.add("B") ;

set1.add("C") ;

set1.add("D") ;

set1.add("F") ;

set1.add("G") ;

System.out.println("set1, the hash set: " + set1) ;

Set set2 = new TreeSet() ;

set2.add("B") ;

set2.add("D") ;

set2.add("E") ;

set2.add("F") ;

set2.add("G") ;

System.out.println("set2, the tree set: " + set2) ;

System.out.println("C is in set1: " + set1.contains("C")) ;

System.out.println("C is in set2: " + set2.contains("C")) ;

System.out.println("Removing C from set1: " +set1.remove("C")) ;

System.out.println("Removing C from set2: " +set2.remove("C")) ;

Set set3 = intersection(set1, set2) ;

System.out.println("Intersection: " + set1 + " ^ " + set2

+ " = " + set3) ;

}

/**

A method that returns the intersection of two sets.

@param x first set

@param y second set

@return the intersection set

*/

public static Set intersection(Set x, Set y)

{

//-----------Start below here. To do: approximate lines of code = 5

// 1. fill in the intersection method

//-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 3 Lnai 6323

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

3642159389, 978-3642159381

More Books

Students also viewed these Databases questions

Question

El porcentaje en masa de zinc en ZnS es %

Answered: 1 week ago

Question

c. What groups were least represented? Why do you think this is so?

Answered: 1 week ago

Question

7. Describe phases of multicultural identity development.

Answered: 1 week ago