Questions
write a persuasive speech on whether online or face to face education/learning is better for students....

write a persuasive speech on whether online or face to face education/learning is better for students.

Includes THESIS STATEMENT WITH 3 POINTS AND 3 SENTENCE OUTLINES from Points

In: Psychology

Applied reserch methods. purpose of study: to determine if the amount of sleep college students get...

Applied reserch methods.

purpose of study: to determine if the amount of sleep college students get affects their academic success

explain the rationale and justification for this study and include the significance of the study

In: Psychology

If 24 students run 24 Casagrande Tests and 24 Thread Rolling Tests, how many different Plasticity...

If 24 students run 24 Casagrande Tests and 24 Thread Rolling Tests, how many different Plasticity Indexes will we most likely see and why?

Paragraph

In: Civil Engineering

Developing the Curriculum: How can schools make the most out of their limited resources to provide...

Developing the Curriculum: How can schools make the most out of their limited resources to provide robust technology opportunities for their students? Use your text and two other sources.

In: Operations Management

Do teachers face a conflict of interest when “certifying” their students? What steps can schools and...

Do teachers face a conflict of interest when “certifying” their students? What steps can schools and potential employers and graduate schools take to eliminate the problems created by these conflicts?

In: Economics

Define and defend your own position on the University of Texas/Texas A& M admissions policy of...

Define and defend your own position on the University of Texas/Texas A& M admissions policy of granting admission to the Top 7-8% of students from Texas High Schools.

In: Economics

After reviewing, the arteries and veins structure, discuss the function of each one of them, then...

After reviewing, the arteries and veins structure, discuss the function of each one of them, then debate with your fellow students the location, structure, and the function of each type of the blood capillaries.

In: Anatomy and Physiology

Write two Java programs ( Iterative and Recursive programs ) that solves Tower of Hanoi problem?use...

Write two Java programs ( Iterative and Recursive programs ) that solves Tower of Hanoi problem?use 4 disks and 3 bars.
Students must send the code and outputs

In: Computer Science

Purpose To learn how to use the JCF classes (HashSet, HashMap, TreeSet, TreeMap). You do not...

Purpose

  • To learn how to use the JCF classes (HashSet, HashMap, TreeSet, TreeMap).
    • You do not need to implement these classes.
  • To practice using the StringBuilder class to reduce runtime when working with Strings.

Time Estimate

4-5 hours to complete.

Background

You have been given the following:

Code

  • setAndMaps.java

Input files

  • imdb.txt
  • sight_and_sound.txt
  • 3_lists.txt

Sample output

  • output_intersection.txt
  • output_frequent.txt
  • output_groupByNumChars.txt

The sample output is produced for the provided main function; mainly, the following cases:

// intersection
System.out.println(setAndMaps.intersection(list1, list2));

// frequent
System.out.println(setAndMaps.frequent(list3, 3));

// groupByNumChars
System.out.println(setAndMaps.groupByNumChars(list2));

Problem Statement

Three of the methods in setAndMaps.java are incomplete. Write the code so it works correctly. You should only code in one file, setAndMaps.java.

Do not change the method signatures. Each method should return the output as a String.

Code Structure

public static List getList(String filename){};

  • This method has been done for you.
    • It takes a filename as a parameter and returns a List of movies.
  • Each file contains one movie per line.
    • 3_lists.txt has duplicates because it contains 3 lists
    • the other files do not have duplicates

public static String intersection(List list1, List list2){};

  • Return all movies that occur in both lists as a String.
    • Your output MUST be ordered alphanumerically (from a-z, 0-9).
  • The expected runtime must be O(nlogn) where n is the total number of movies in the lists.
  • Use a HashSet to store one of the lists, so you can search the HashSet efficiently.
    • You may assume that the expected runtime of searching or inserting into a hash table is O(1).
  • Do not call the list's contains method, because it is too slow.
  • Return all entries (do not deduplicate your result).

public static String frequent(List list, int k){};

  • Return all movies in the list that occur at least k times as a String.
    • Your output MUST be ordered alphanumerically (from a-z, 0-9).
  • The output String will contain the movie followed by the number of occurrences in parentheses, as in the sample output.
  • The expected runtime must be O(nlogn) where n is the total number of movies in the list.
  • Use a HashMap to count occurrences
    • the key is the movie
    • the value is the number of occurrences
  • For each movie, check if it's a key in the map.
    • If it is, update its value.
    • Otherwise add a new entry to the map.
  • Then iterate through the map and print the frequent movies.
    • See UsingSetsMaps for an example of how use a for-each loop with a map.

public static String groupByNumChars(List list){};

  • Return all movies in the list, grouped by number of characters, as a String.
    • All movies with the same number of characters should be printed on the same line
    • Movies with fewer characters should be printed first.
    • Your output MUST be ordered alphanumerically (from a-z, 0-9).

Advice

  • There is more than one way to solve this problem, but one way is to use a map.
    • The key is the number of characters, and the value is a list of movies with that number of characters.
    • You can declare it like this:
Map> map = new ... // Choose the appropriate map class
  • For each movie, you can use the String class's length function to get the number of characters.

    • If the map doesn't already have an entry for this length, create a new entry
      • use the map's put method
    • If the map already has an entry for this length:
      • first call the map's get method (which returns a reference to a list)
      • then add the movie to the list
  • Do not use a single String to store more than one movie, because it will slow down the runtime

    • a StringBuilder is fine.

Requirements

  • The program takes in text files that are then converted to lists. Your solutions will operate on the parameterized lists.

  • The code must properly complete the setAndMaps.java class and work with the provided Main.java class.

  • All functions in the setAndMaps.java class MUST be implemented.

  • All code you write should exist solely in the specified methods and additional helper functions. NO CODE SHOULD BE ADDED TO THE MAIN FUNCTION

  • Base your code on the given template. Any code not adhering to the given template may work, but may not pass all tests upon submission.

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main {
   // Returns a List of all movies in the specified file (assume there is one movie per line).
   public static ArrayList getList(String filename) {
   ArrayList list = new 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) {
       ArrayList list1 = getList("imdb.txt");
       ArrayList list2 = getList("sight_and_sound.txt");
       ArrayList list3 = getList("3_lists.txt");

//Sort lists
Collections.sort(list1);
Collections.sort(list2);
Collections.sort(list3);
  
       System.out.println("***\nintersection\n***");
       System.out.println(setAndMaps.intersection(list1, list2));

       System.out.println("***\nfrequent\n***");
       System.out.println(setAndMaps.frequent(list3, 3));

       System.out.println("***\ngroupByNumChars\n***");
       System.out.println(setAndMaps.groupByNumChars(list2));
   }
}

import java.util.*;

BELOW IS WHERE WE DO THE CODE

public class setAndMaps {

// Prints all movies that occur in both lists.
public static String intersection(List<String> list1, List<String> list2) {
//Add code below
return "";
}

// Prints all movies in the list that occur at least k times
// (print the movie followed by the number of occurrences in parentheses).
public static String frequent(List<String> list, int k) {
//Add code below
return "";
}

// Prints all movies in the list, grouped by number of characters.
// All movies with the same number of characters are printed on the same line.
// Movies with fewer characters are listed first.
public static String groupByNumChars(List<String> list) {
//Add code below
return "";
}
}

In: Computer Science

Listed below are several terms and phrases associated with property, plant, and equipment and intangible assets.

Listed below are several terms and phrases associated with property, plant, and equipment and intangible assets. Pair each item from List A with the item from List B (by letter) that is most appropriately associated with it. 

List A List B 1. Property, plant, and equipment 2. Land improvements a. Exclusive right to display a word, a symbol, or an emblem. b. Exclusive right to benefit from a creative work. c. Assets that represent rights. d. Costs of establishing parking lots, driveways, and private roads. e. Purchase

In: Accounting