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: 9780134700144
Author: Liang
Publisher: PEARSON
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
2:21 m Ο 21% AlmaNet WE ARE HIRING Experienced Freshers Salesforce Platform Developer APPLY NOW SEND YOUR CV: Email: hr.almanet@gmail.com Contact: +91 6264643660 Visit: www.almanet.in Locations: India, USA, UK, Vietnam (Remote & Hybrid Options Available)
Provide a detailed explanation of the architecture on the diagram
hello please explain the architecture in the diagram below. thanks you
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