Here is the code for the above assignment.
Feel free to comment on any doubt and give thumbs up!
Code:
import java.util.HashMap;
public class Lab7b
{
public static void main(String[] args) {
// Create a new HashMap called "songsStarts"
HashMap<String, Integer> songStars = new HashMap<>();
// Yes, you should listen to all these on Youtube
songStars.put("The balled of Bilbo Baggins", 5);
songStars.put("A still more glorious dawn", 4);
songStars.put("A finite simple group of order two", 4);
songStars.put("Code monkey", 2);
songStars.put("Fish heads", 2);
songStars.put("I;ll form the head", 3);
songStars.put("Honeybee", 5);
songStars.put("Silver apples of the moon", 4);
// Get the number of stars for "Code monkey", and print the # of stars
int numberOfStars = songStars.get("Code monkey");
System.out.println("Number of stars for the song Code monkey on Youtube are : " + numberOfStars);
// Remove the song "Honeybee"
songStars.remove("Honeybee");
// Determine if "Honeybee" is still in the table.
if(songStars.containsKey("Honeybee")){
System.out.println("Honeybee still in table");
}else{
System.out.println("Successfully removed Honeybee");
}
}
}
Screenshot

Thank You!
__________________________________________________________________________________________ HashMaps A hashtable is a data structure that allows the user to look up things...
Use Java language You may assume that you always map strings to integers, and therefore you need not worry about using generics. Here are the methods that your map must implement. void put (String key, Integer value); insert this key-value pair into the map under the following rules: If key already exists in the map, change its value to value, overwriting what was there If key is not already there, insert this key-value pair into the map. boolean containsKey(String key);...
Please answer this problem in C++, Thank you! Read and study the sample program: "hashing with chaining using singly linked lists", as well as "hashing with chaining using doubly linked lists". Notice this program is complete except it doesn't include the remove function. Write the remove function and test it with the rest of the program including the given main program. Upload your C++ source file. ---Here is the referenced program: "hashing with chaining using singly linked lists". Below this...
Java you are required to add a public Object get( Object key) method into the Hashtable class. As defined in the Java documentation, the get() method returns the value with which the specified key is associated, or null if this hash table contains no record for the key. More formally, if this hash table contains a mapping from a key k to a value v such that (key.equals(k)), then this method returns v; otherwise it returns null. (There can be...
Hey guys I need help with this assignment. However it contains 7
sub-problems to solve but I figured only 4 of them can be solved in
one post so I posted the other on another question so please check
them out as well :)
Here is the questions in this assignment:
Note: Two helper functions Some of the testing codes for the functions in this assignment makes use of the print_dict in_key_order (a dict) function which prints dictionary keyvalue pairs...
PROGRAM DESCRIPTION Implement a hash table class. Your hash table should resolve collisions by chaining and use the multiplication method to generate hash keys. You may use your own linked list code from a previous assignment or you can use a standard sequence container. Partial definitions for the hash table class and a generic data class are provided (C++ and Java versions). You may use them as a starting point if you wish. If you choose to design your own...
Write a program that allows the user to enter an unsigned integer (the maximum value of an unsigned 4-byte int is 232 = 4,294,967,296) and reverses its format (from little to big endian, or vice versa). Print out the user-entered number in hexadecimal and binary, reverse the endianness, and print the reverse in hexadecimal and binary. Integers in most machine architectures are represented in little endian format: the least significant byte is stored in the smallest address; for instance, the...
Implement the remove() and the rehash() methods for the following externally chained hash table. Note you should rehash when "size > arraySize" at the start of the put() method. The new size of the arraySize should be "(2 * old array size) + 1" import java.util.ArrayList; import java.util.Hashtable; import java.util.LinkedList; import java.util.Map; public class ExternalChainingHashTable<K,V> { private class Mapping { private Mapping next; private K key; private V value; private Mapping(K key, V value) { this.key = key; this.value =...
This should be in Java Create a simple hash table You should use an array for the hash table, start with a size of 5 and when you get to 80% capacity double the size of your array each time. You should create a class to hold the data, which will be a key, value pair You should use an integer for you key, and a String for your value. For this lab assignment, we will keep it simple Use...
-----------Python
program-------------------
Instructions: For this assignment, you will
write complete a program that allows a customer to plan for
retirement.
Part 2: Generate a Retirement Planning
Table:
It's hard to decide how much you need to save for retirement. To
help your customer visualize how long her nest egg will last, write
a program that allows the user to generate a retirement
planning table showing the number of months the savings
will last for various combinations of starting account balance...
Declare the following three variables: char letter; int number; double decimalNumber; Prompt the user to enter a letter. Read the letter into the variable letter Assign to the variable number the value from the variable letter Assign to the variable decimalNumber the value from the variable number Print the values of the three variables using the following format: Character: K Number: 75 Decimal number: 75 Test the program with the input letter a and copy the results into a comment...