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.2PE
Program Plan Intro

MyMap using Open Addressing with Quadratic Probing

Program Plan:

  • Define a class named “Sample” to implement MyMap using open addressing with quadratic probing.
    • Define function main.
      • Define an integer HashMap named “map”.
      • Put ‘2, 2” into the map.
      • Remove “2” from the map.
    • Define a static class named “MyHashMap” and implement “MyMap”.
      • Define required variables.
      • Define a function named “MyHashMap”.
        • Construct a map with the default capacity and load factor.
      • Define a function named “MyHashMap” with one parameter.
        • Construct a map with the specific initial capacity and default load factor.
      • Define a function named “MyHashMap” with two parameters.
        • Construct a map with the default capacity and load factor.
      • Define a function named “clear”.
        • Remove all of the entries from this map.
      • Define a function named “containsKey”.
        • Return true if the specified key is in the map.
      • Define a function named “containsValue”.
        • Return true if this map contains the specific value.
      • Define a function named “entrySet”.
        • Return a set of entries in the map.
      • Define a function named “get”.
        • Return the first value that matches the specific key.
      • Define a function named “getAll”.
        • Return all values for the specified key in this map.
      • Define a function named “isEmpty”.
        • Return true if this map contains no entries.
      • Define a function named “keyset”.
        • Return a set consisting of the keys in this map.
      • Define a function named “put”.
        • Add an entry (key, value) into the map and return the value.
      • Define a function named “remove”.
        • Remove the element for the specific key.
      • Define a function named “size”.
        • Return the number of mappings in this map.
      • Define a function named “values”.
        • Return a set consisting of the values in this map.
      • Define a function named “hash”.
        • Return “hashCode % capacity” value.
      • Define a function named “supplmentHash”.
        • Ensure the hashing is evenly distributed and return the result.
      • Define a function named “removeEntries”.
        • Remove all entries from each bucket.
      • Define a function named “rehash”.
        • Rehash this map.
      • Define a function named “toString”.
        • Return a string representing for this map.
    • Define an interface name “MyMap”.
      • Declare function prototypes for the functions which are created at the class “MyHashMap”.

Blurred answer
Students have asked these similar questions
- In class HashTable implement a hash table and consider the following:(i) Keys are integers (therefore also negative!) and should be stored in the tableint[] data.(ii) As a hash function take h(x) = (x · 701) mod 2000. The size of the table istherefore 2000. Be careful when computing the index of a negative key. Forexample, the index of the key x = −10 ish(−10) = (−7010) mod 2000 = (2000(−4) + 990) mod 2000 = 990.Hence, indices should be non-negative integers between 0 and 1999!(iii) Implement insert, which takes an integer and inserts it into a table. Themethod returns true, if the insertion is successful. If an element is already inthe table, the function insert should return false.(iv) Implement search, which takes an integer and finds it in the table. The methodreturns true, if the search is successful and false otherwise.(v) Implement delete, which takes an integer and deletes it form the table. Themethod returns true, if the deletion is successful and false otherwise.(vi)…
Q: Hash table is a data structure in which keys are mapped to array positions by a hash function. Theprocess of mapping the keys to appropriate locations in a hash table is called hashing. Hash functions areused to reduce the number of collisions.i. Mention the methods to minimize collision.ii. Explain the advantage of using double hashing over linear and quadratic probing techniques.iii. Load the keys given below in a hash table of size 7 in the same order using chaining with thehash function h(key)= key % 7. Show graphically how collisions are resolved using chainingin this particular case.12, 101, 3, 21, 14, 13, 16, 7, 141
9) Implement an overflow check for multiplication where the two numbers being multiplied areboth always positive. Why is this simpler than the generic check implement in the mulooperator?
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