Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
Question
Book Icon
Chapter 27, Problem 27.11PE
Program Plan Intro

Set operations in MyHashSet

Program Plan:

  • Include a class name named “Exercise_11”.
    • Import util package.
    • Declare the main() method.
    • Declare constructor.
    • Create array for string names.
    • Take user inputs and add into respective arrays.
    • Create new Hashset.
    • Add elements from set1 into set2.
    • Remove all elements present in set1 from set 2.
    • Retain elements present in set2 and set1.
    • Check if set1 and set2 contains same elements.
    • Close the main() method.
    • Close the class.
  • Include a static class “MyHashSet”.
    • Define the default hash table size. Must be a power of 2.
    • Define the maximum hash table size. 1 << 30 is same as 2^30.
    • Declare current hash table capacity. Capacity is a power of 2.
    • Define default load factor.
    • Specify a load factor threshold used in the hash table.
    • Declare a Hash table that is an array with each cell that is a linked list.
    • Declare a constructor to Construct a set with the default capacity and load factor.
    • Declare a constructor to Construct a set with the specific capacity and load factor.
    • Declare an override method that Remove all elements from this set.
    • Declare an override method that Return true if the element is in the set.
    • Declare an override method that adds an element to the set.
    • Create a linked list for the bucket if it is not created.
    • Declare an override method that Remove the element from the set.
    • Declare an override method that Return the number of elements in the set.
    • Declare an override method to return the number of iterators.

Blurred answer
Students have asked these similar questions
(Implement set operations in MyList)(JAVA) Please use class name: Exercise_01 The implementations of the methods addAll, removeAll, retainAll, toArray(), and toArray(T[]) are omitted in the MyList interface. Implement these methods. Test your new MyList class using the code at https://liveexample.pearsoncmg.com/test/Exercise24_01.txt. Sample Output: Enter five strings for array name1 separated by space: TomGeorgePeterJeanJaneEnter five strings for array name2 separated by space: TomGeorgeMichaelMichelleDanielEnter two strings for array name3 separated by space: TomPeterlist1:[Tom, George, Peter, Jean, Jane]list2:[Tom, George, Michael, Michelle, Daniel]After addAll:[Tom, George, Peter, Jean, Jane, Tom, George, Michael, Michelle, Daniel] list1:[Tom, George, Peter, Jean, Jane]list2:[Tom, George, Michael, Michelle, Daniel]After removeAll:[Peter, Jean, Jane] list1:[Tom, George, Peter, Jean, Jane]list2:[Tom, George, Michael, Michelle, Daniel]After retainAll:[Tom, George] list1:[Tom, George,…
Below is the specs and my main method. (ignore add and remove method for now) Specs:  Part 1 - Tweet Bot To start analyzing tweets, we first need to read in and manage the state of tweets. To do this, create a class called TweetBot. A TweetBot should have the following constructor and methods: Constructor public TweetBot(List<String> tweets) Given a List of tweets, initialize a tweet list containing all tweets from the given collection. Note that you should not initialize your tweet list to the given List reference. You should create a new data structure and copy over all of the tweets from the given List, leaving the given List unmodified after the constructor is finished executing. Throws an IllegalArgumentException if the size of the given collection is less than 1. You may assume the given collection contains only non-empty and distinct strings. Methods public int numTweets() Returns the number of tweets currently in the tweet list. public void addTweet(String tweet) Adds the…
(see image for code) Consider the following code. Replace the tags _??1_ and _??2_, respectively, by filling in the text fields below, such that running printGenericCollection(c) prints the contents of the Collection object c the console:
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education