(i) A dictionary is a concept that maps keys to values. There are many ways to implement such mapping. One such method is the hash table. Using a hash function, a hash table calculates an index into an array of buckets/slots, which is then used to find the desired values.
An advantage of such a data structure is speed. This can be practically observed when there is a lot of data. When the maximum number of entries can be predicted in advance, hash tables can be particularly efficient because the bucket array can be allocated once with the optimum size.
Insertion is fast (assuming less collisions on an average) as the location of insert is calculated based on the hash function. A direct effect of this is that searching a hash table is considerably faster than a list-based structure, as the hash for the search item can be calculated, and the possible location(s) can be directly accessed to check whether the element is present.
(ii) Hash tables are used for database indexing, caching etc.
(iii) Another common way to implement dictionaries is red-black trees. Each method has its own advantages and disadvantages. A red-black tree, for example, can always perform a lookup in O(log N). A hashtable can perform a lookup in O(1) time, although that can degrade to O(N) depending on the hash function and the input.
(iv) Depending on the implementation, a dictionary ADT may or may not allow null keys. Even if they do, there can be only one null key, as keys must be unique. This can be thought of like a default case. A lot of implementations will simply throw a null pointer exception when attempting to insert an entry with a null key. Null values are allowed because it is possible for multiple keys to contain no data. Values can repeat.
(v) Depending on the characteristics of a dataset, it is important to decide a few things: the hash function, bucket size, implementation type (hash table, red-black trees...), whether to allow null key etc. These features can be decided based on the data AND the requirements and general access trends for the data by the application.
Hope this answers your question. All the best!
In general, how useful is the Dictionary/Hash Table data structure? Can you think of other uses...
1. In general, how useful is the Queue data structure? Can you think of other data structure? 2. If we didn’t have the Queue data structure, can you think of another way to implement the FIFO (first in first out) concept? Can the Queue ADT accept/handle null entries? Why or why not?
Design a primary hash table data structure. a. Each hash table has an array of node pointers and can point a head of a linked list. Suppose the node class is given to you. The data type of each node is int. b. Override the default constructor with a constructor that has one default parameter called capacity. What happens to your default constructor? Create some instances of the sequence class using the new constructor in multiple ways. c. Design the...
The task of this project is to implement in Java Hash Table structure using Linear Probing Collision Strategy. You can assume that no duplicates or allowed and perform lazy deletion (similar to BST). Specification Create a generic class called HashTableLinearProbe <K,V>, where K is the key and V is the value. It should contain a private static class, HashEntry<K,V>. Use this class to create array to represent Hashtable: HashEntry<K,V> hashtable[]; Implement all methods listed below and test each method...
C programming Problem 3 [Set via Hashing] As mentioned in the lecture, a hash table can be used to implement a Set ADT. Let's try to use the template below to implement a Set with double hashing. Here we assume the Set contains names with 3 characters long. Since it is a Set, we do not need to have an explicit value for each key. We will use a token value of 1 if a name belongs to the Set....
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...
Java using data structures The objective is to create your own Hash Table class to hold a list of employees and their ID numbers. I've provided the TableEntry class which will be each data object in the hash table. The list of employees will be provided as a .txt file and must be read with the code. please create a .txt file called Employees.txt with the info provided so that the java code can read it in. Employees.txt: (No WhiteSpace...
3. How can you implement a queue data structure using a doubly linked list? Do you think it is necessary to use a doubly linked list rather than a singly linked list or not?(3 marks)
3. How can you implement a queue data structure using a doubly linked list? Do you think it is necessary to use a doubly linked list rather than a singly linked list or not?(3 marks)
You are designing a table for employee data of a company. You have a requirement to identify if an employee is a United States citizen or not. You have designed a table called EMPLOYEE to store information related to each employee and you have a column called US CITIZEN INDICATOR to store if an employee is a US citizen or not. You only want to store values "Y" or "N" in this column. From the following options, what is the...
Following class is only part of my program that uses a hash table to simulate a market's client database, client class is my main class which asks user to input client names and then creates a hash table which then users can look up client names. wasn't able to upload everything as it is too much code, but what I need is to modify my client class instead of me inputting data line by line, the program should read from...
Using the data structure concept of hashing demonstrate using pseudocode how you can implement an operation to recommend location to retrieve product in a warehouse during issuing.