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
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
6. the grade is under 20 which is outlier, remove it from the array list. 7. Print array list using System.out.println() 8. Use indexOf to print index of 80. 9. Use get function. 10. What is the difference between get and index of? 11. Print the values of the array list using Iterator class. 12.. Delete all the values of the array list using clear function. 13. Print all the values of the array after you execute clear using System.out.println(). what is the result of using clear function? 14. What is the shortcoming of using array List?
Q1. Write the following method that returns thesmallest element in an ArrayList:public static <E extends Comparable<E>> E min(ArrayList<E> list).
HW: Write a method to sort an array of elements at index in a single linked list and then display this list. (In java)
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
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