Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
11th Edition
ISBN: 9780134671710
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
When the FCC added Color Television to the Industry Standards, they went with the system developed in the 1940s by Peter Goldman for CBS.   Question 15 options:   True   False Part of the reason that many critics disliked 1950s gameshows was the fact that gameshows offered one of the few opportunities to see unscripted interactions with "real" (average/non-famous) people on television.   Question 16 options:   True   False The Andy Griffith Show is an example of the "rural revival" shows that become enormously popular on 1960s American television.   Question 19 options:   True   False During the Network Era, the hours before primetime each day were exclusively devoted to locally-produced programming, not programming dictated by an affiliate station's parent network.   Question 20 options:   True   False
Although color television was not added to the industry standard until 1956, CBS had been broadcasting selected special events in color as early as 1950.   Question 1 options:   True   False Two key factors in creating the Network Era of American television were the FCC licensing freeze and ______________.   Question 4 options:   The Quiz Show Scandals   Habitual Viewing   Operation Frontal Lobes   Drop-In Viewing Least Objectionable Programming was designed to embrace the public service-oriented vision of using television to elevate mass culture and enrich viewers.   Question 6 options:   True   False By the end of the 1950s, all three remaining networks (NBC, CBS, & ABC) were broadcasting their entire nightly programming schedule in full color.   Question 9 options:   True   False
7. See the code below and solve the following. public class Test { public static void main(String[] args) { int result = 0; } result = fn(2,3); System.out.println("The result is: + result); // fn(x, 1) = x // fn(x, y) = fn(x, y-1) + 2, when y>1 public static int fn(int x, int y) { if (x <= 1) return x; else return fn(x, y-1) + 2; } } 7-1. This program has a bug that leads to infinite recursion. Modify fn(int x, int y) method to fix the problem. (2 point) 7-2. Manually trace the recursive call, fn(2,3) and show the output (step by step). (2 point) 7-3. Can you identify the Base Case in recursive method fn(int x, int y)? (1 point)
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