bartleby

Concept explainers

Question
Book Icon
Chapter 27, Problem 27.10PE
Program Plan Intro

MyHashSet.java

Program Plan:

  • Include a class name named “Exercise_10”.
    • Declare the main() method.
    • Shuffle the data.
    • Create a new arrayList.
    • Create a new HashSet.
    • Add integers into the hash set.
    • Add current time.
    • Add integers into the arraylist.
    • Close the main() method.
    • Close the class.
  • Include a static class “MyArrayList”.
    • Declare all the data types of the variables.
    • Create data array.
    • Create a default list constructor.
    • Create a list from an array of objects.
      • User shouldn't add super(objects)!
    • Override method to add a new element at the specified index.
      • The elements are moved to the right after the specified index.
      • New elements are inserted to data[index].
    • Declare a method to create a new larger array and double its current size + 1.
    • Override method to clear the list.
    • Override method to return true if this list contains the element.
    • Override method to return the element at the specified index.
    • Override method to return the index of the first matching element in this list and return -1 if no match.
    • Override method to return the index of the last matching element in this list and return -1 if no match.
    • Override method to replace the element at the specified position in this list with the specified element.
    • Declare a Method to trim the capacity to current size.
    • Close class.
  • Include a class “Iterator”.
    • Declare current index.
    • Declare a Boolean method hasNext().
    • Declare a method remove().
    • Close class.
  • Include an interface “MyList”.
    • Declare a Method to add a new element at the end of this list.
  • Declare a method to add a new element at the specified index in this list.
    • Declare a method to clear the list.
  • Declare a Method to return true if this list contains the element.
    • Declare a Method to return the element from this list at the specified index.
  • Declare a method to remove the first occurrence of the element o from this list. Shift any subsequent elements to the left. Return true if the element is removed.
    • Declare a Method to remove the element at the specified position in this list Shift any subsequent elements to the left. Return the element that was removed from the list.
  • Declare a method to replace the element at the specified position in this list with the specified element and returns the new set.
  • Include a static abstract class “ MyAbstractList”.
    • Declare the size of the list.
    • Define a Constructor to create a default list.
    • Define a constructor to create a list from an array of objects.
    • Declare an override method to add a new element at the end of this list.
    • Declare an override method to return the number of elements in this list.
    • Declare an override method to remove the first occurrence of the element e from this list. Shift any subsequent elements to the left.  Return true if the element is removed
    • Declare a method that adds the elements in otherList to this list. Returns true if this list changed as a result of the call.
    • Declare a method that removes all the elements in otherList from this list Returns true if this list changed as a result of the call.
  • 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.
  • Include an inner class named “MyHashSetIterator”.
    • Declare an inner class for iterator.
    • Store the elements in a list.
    • Declare a constructor to create a list from the set.
    • Declare an override the next element for traversing.

      Declare an override method that remove the current element and refresh the list.

    • Declare a Method to ensure the hashing is evenly distributed.
    • Declare a Method to return a power of 2 for initial Capacity.
    • Declare a method to Remove all e from each bucket.
    • Declare a method to Rehash the set

Blurred answer
Students have asked these similar questions
Which tool takes the 2 provided input datasets and produces the following output dataset? Input 1: Record First Last Output: 1 Enzo Cordova Record 2 Maggie Freelund Input 2: Record Frist Last MI ? First 1 Enzo Last MI Cordova [Null] 2 Maggie Freelund [Null] 3 Jason Wayans T. 4 Ruby Landry [Null] 1 Jason Wayans T. 5 Devonn Unger [Null] 2 Ruby Landry [Null] 6 Bradley Freelund [Null] 3 Devonn Unger [Null] 4 Bradley Freelund [Null] OA. Append Fields O B. Union OC. Join OD. Find Replace Clear selection
What are the similarities and differences between massively parallel processing systems and grid computing. with references
Modular Program Structure. Analysis of Structured Programming Examples. Ways to Reduce Coupling. Based on the given problem, create an algorithm and a block diagram, and write the program code: Function: y=xsin⁡x Interval: [0,π] Requirements: Create a graph of the function. Show the coordinates (x and y). Choose your own scale and show it in the block diagram. Create a block diagram based on the algorithm. Write the program code in Python. Requirements: Each step in the block diagram must be clearly shown. The graph of the function must be drawn and saved (in PNG format). Write the code in a modular way (functions and the main part should be separate). Please explain and describe the results in detail.

Chapter 27 Solutions

Instructor Solutions Manual For Introduction To Java Programming And Data Structures, Comprehensive Version, 11th Edition

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Text book image
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage