Professional Documents
Culture Documents
Hash Table
Is a data structure which stores data in an associative manner. In a hash table, data is stored in
an array format, where each data value has its own unique index value. Access of data becomes very
fast if we know the index of the desired data.
Explanation:anongaba ang hash table, hash table is a data structure which stores data, sa hash
table ay maiistore mo ang mga data ng naka array format and it makes ure work more convenient if u
know what is the index ng impormasyon na gusto mo
Linear Probing
As we can see, it may happen that the hashing technique is used to create an already used index
of the array. In such a case, we can search the next empty location in the array by looking into the next
cell until we find an empty cell. This technique is called linear probing.
Explanation: if hashing is used to create and already used index ang linear probing namn ay
mahahanap mo if u look into the next location at nkakakita ka ng empty cell that’s called linear probing
Basic Operations
Following are the basic primary operations of a hash table.
Search − Searches an element in a hash table.
Explanation:Basically ito ay ginagamit para maghanap at para mas mabilis mong makita or
makuha ang data na gusto mo
Insert − inserts an element in a hash table.
Explanation: Insert it puts element in the hast table kunware di sapat ang isang element edi
maginsert ka ng lima problem solved
delete − Deletes an element from a hash table.
Explanation: if u made a mistake in the hash table don’t worry coz theres an option where u can
delete it
DataItem
Define a data item having some data and key, based on which the search is to be conducted in a
hash table.
Explanation: dataltel is ito yung nagbibigay linaw or nagdedefine sa mga data na may data or
keys depende sa search na ginawa mo for example look at the pic below
struct DataItem {
int data;
int key;
};
Hash Method
Define a hashing method to compute the hash code of the key of the data item.
Explanation: kanina is yung hashing technique tinalakay naten ngayon naman is yung
hash method nmn so this is a an easy process where u can easily define a hash method and
compute it to know the key of the data item look at the pic below
Search Operation
Whenever an element is to be searched, compute the hash code of the key passed and locate
the element using that hash code as index in the array. Use linear probing to get the element ahead if
the element is not found at the computed hash code.
Explanation: search operation can be used if u wanna find an element bali kailangan mong
icompute ang hash code ng key tapos locate and use mo itong sa index and u if u got confuse or if u cant
compute u can use the linear probing which we discussed earlier so it’s a second option look at the pic
below for an example
Example:
struct DataItem *search(int key) {
//get the hash
int hashIndex = hashCode(key);
if(hashArray[hashIndex]->key == key)
return hashArray[hashIndex];
return NULL;
}
Insert Operation
Whenever an element is to be inserted, compute the hash code of the key passed and locate the
index using that hash code as an index in the array. Use linear probing for empty location, if an element
is found at the computed hash code.\
Explanation:so insert operation is same sa search operation ang pinagakaiba lang is in the search u
coumpute to search but here magcocompute ka ng hash code para maglagay ng new element sa hash
table look at the pic below
Example:
void insert(int key,int data) {
struct DataItem *item = (struct DataItem*) malloc(sizeof(struct
DataItem));
item->data = data;
item->key = key;
hashArray[hashIndex] = item;
}
Delete Operation
Whenever an element is to be deleted, compute the hash code of the key passed and locate the
index using that hash code as an index in the array. Use linear probing to get the element ahead if an
element is not found at the computed hash code. When found, store a dummy item there to keep the
performance of the hash table intact.
Explanation; so it’s the same as the search and insert so lets make it short if u wanna delete an
elemet coumpte the hash code and use linear probing incase cant find and kung Nakita mona maglagay
ka ng dummy item so the performance of the table will be intact look at the pic below
Example:
struct DataItem* delete(struct DataItem* item) {
int key = item->key;
return NULL;
}
Reference:
https://www.tutorialspoint.com/data_structures_algorithms/hash_data_structure.htm
GROUP 7: HASHING
MEMBERS:
KAYCELYN SAMBALES
GIAN CARLO SANTIAGO
MONICA SUNGA
EMRIEL ISIP
JOHN CHRISTOPHER GUTIERREZ