


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Hashing is a technique used in data structures that efficiently stores and retrieves data in a way that allows for quick access. Hashing involves mapping data to a specific index in a hash table (an array of items) using a hash function that enables fast retrieval of information based on its key.
Typology: Slides
1 / 4
This page cannot be seen from the preview
Don't miss anything!
Hash function H(x) maps the value x at the index x%10 in an Array.
struct DataItem *search(int key) { //get the hash int hashIndex = hashCode(key); if(hashArray[hashIndex]->key == key) return hashArray[hashIndex]; return NULL; }
void insert(int key,int data) { struct DataItem item = (struct DataItem) malloc(sizeof(struct DataItem)); item->data = data; item->key = key; //get the hash int hashIndex = hashCode(key); hashArray[hashIndex] = item; }