Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

////Please fill in the methods for intersection, frequents k times and group_by_years. You can find this methods in HW2.java /////////////////////////////////1001_movies.txt //rosenbaum.txt //all_lists.txt // sightsound_with_years.txt //Please

image text in transcribed

////Please fill in the methods for intersection, frequents k times and group_by_years. You can find this methods in HW2.java

/////////////////////////////////1001_movies.txt

image text in transcribed

//rosenbaum.txt

image text in transcribed

//all_lists.txt

image text in transcribed

// sightsound_with_years.txt

image text in transcribed

//Please fill in the methods for intersection, frequents k times and group_by_years. You can find this methods in HW2.java

import java.io.* import java.util.*; public class HW2 Prints all movies that occur in both lists. public static vold intersection (List list1, List list2) { Prints all movies in the 1list that occur at least k times // (print the movie followed by the number of occurrences in parentheses) public static void frequent (List list, int k) Prints all movies in the list, grouped by year. // All movies from the same year should be printed on the same line. / Earlier years should be listed first. public static void groupByYear (List list) { // Returns a List of all movies in the specified file (assume there is one movie per line). public static List getList (String filename) { List listnew ArrayList try (Scanner in = new Scanner (new FileReader (filename))) { while (in.hasNextLine)) String line = in.nextLine(); list.add (line); catch (FileNotFoundException e) e.printstackTrace return list; public static void main(String[] args) 11st1 11st2 list3 11st4 ListString> ListString> List getList ("1001-movies.txt " ); getList ("rosenbaum .txt " ); getList ("all-lists.txt"); getList("sightsound with years. txt"); = = System.out.println("***intersection***") ; intersection (listl, list2) systernout .println (" frequent (list3, 3) frequent " ) ; System.out.println("*groupByYear***"); groupByYear (list4)

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

Database Design And Relational Theory Normal Forms And All That Jazz

Authors: Chris Date

1st Edition

1449328016, 978-1449328016

More Books

Students also viewed these Databases questions