answersLogoWhite

0

Insertion in hash tables is based on a 'key' value which is calculated on the basis of a hash function.

This hash function generates the key based on what type of data it is fed.

For example hash function for an integer input might look like this :

int hash(int val)

{

return (val%101);

}

where return value of hash function would become a key.

Complete implementation can be found at: http://simplestcodings.blogspot.com/2010/07/hash-table.html

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

What is hash key?

hash key is an element in the hash table. it is the data that you will combine (mathematical) with hash function to produce the hash.


What is hash table in sql?

temp table


Advantage and distadvantage in hash table?

ANSWER A hash table is a way to find data in an array, when you have a known key and an unknown value that corresponds to the key. You use a hashing function on the key to create an index into the hash table containing the value. In the ideal case, this directly returns the corresponding value. In the usual case, a collision can occur. This means that the hashed key points to multiple possible values. A hash table is usually used on large arrays that would take a long time to search using other methods. A hash table can be very fast and use very little memory, and does not require the array to be sorted. The source code is slightly more complicated than some search methods. With a poorly designed hashing function when the hashed keys do not correspond one-to-one with the values, the secondary search after a hash collision can take a large amount of time.


What is the major advantage of a hash table?

The major advantage of a hash table is its speed. Because the hash function is to take a range of key values and transform them into index values in such a way that the key values are distributed randomly across all the indices of a hash table.


How do you insert a row into a table?

Row can be inserted in to a database using DML (data manipulation language). Example :- insert into table_name [<colum_list>] values (<value 1>, <value 2>, ...);


Which hash algorithm is a 160 bit hash value?

Some well-known hash algorithms with a 160-bit output:RIPEMMD-160SHA-0/SHA-1Tiger-160


What are the three rules for a forensic hash?

The same input will always produce the same hash. It is a one-way function, meaning it is difficult to reverse the process and obtain the original input from the hash. A small change in the input will produce a significantly different hash value.


How do you use hash table?

In computer science, a hash table, or a hash map, is a data structure that associates keys with values. The primary operation it supports efficiently is a lookup: given a key (e.g. a person's name), find the corresponding value (e.g. that person's telephone number). It works by transforming the key using a hash function into a hash, a number that is used as an index in an array to locate the desired location ("bucket") where the values should be. Hash tables support the efficient insertion of new entries, in expected O(1) time. The time spent in searching depends on the hash function and the load of the hash table; both insertion and search approach O(1) time with well chosen values and hashes.


Can You insert a row containing a null attribute value using SQL?

You cannot do it, if the column is not null in the table. Assuming you have a table TBL with columns a, b, c insert into TBL (a, b, c) values ('AAA', null, 'BBB') Now, the value null would be stored in the database for the column 'b'


C plus plus program to implement quadratic probing?

Quadratic probing is a collision resolution technique used in hash tables. In C++, you can implement it by defining a hash table class and a hash function, then using a quadratic formula to calculate the next index when a collision occurs. The formula typically used is (hash + i^2) % table_size, where i is the number of attempts. Here's a simple implementation outline: #include <iostream> #include <vector> class QuadraticProbingHashTable { std::vector<int> table; int size; public: QuadraticProbingHashTable(int s) : size(s), table(s, -1) {} void insert(int key) { int index = key % size; int i = 0; while (table[index] != -1) { index = (index + i * i) % size; // Quadratic probing i++; } table[index] = key; } void display() { for (int i = 0; i < size; i++) std::cout << i << ": " << table[i] << std::endl; } }; This code snippet initializes a hash table, inserts keys using quadratic probing, and displays the table's contents.


What tab do you click on to insert a table?

On versions of Word prior to the introduction of ribbons, there is a Table menu and on that you will find the Insert sub-menu from which you can insert a table.


What are the two ways of making a textual presentation of a table?

1-From Insert Menu choose "Insert Table". 2-From slide content choose insert Table.