Hello दोस्तों! आज मैं आपको इस पोस्ट में Types of hashing in Data Structure in Hindi के बारें में बताऊंगा, और इसके example को भी पढेंगे, तो चलिए शुरू करते हैं:-
Contents
Types of hashing
(1) Hash Function
(2) Collision Resolution
what is Hash Function:-
Hash Function को select करने के लिए 2 principles को use मे लिया जाता है ।
एक function H बहुत easy तथा quick computation को perform करता है
hash function hash address को uniformly distribute करता है जिससे कम से कम collision occur होते है
what is Collision Resolution:-
माना को हम एक नये record R को Key K के साथ file F मे add करना चाहते है
लेकिन memory location जहां पर नये record को add करना है वह full हा तो इस प्रकार की condition collision कहलाती है
collision को दूर करने के लिए कुछ techniques को use मे लिया जाता है ।
Normally collision को avoid करना impossible है जैसे एक class मे 24 students है और एक table मे 365 records का space है
एक random hash function के द्वारा student के Birthday को choose किया जाता है ।
Hash function की efficiency को collision के solution के procedure के आधार पर major किया जाता है
इसके लिए key comparison की आवश्यकता होती है जिससे specific record की location find किया जाता है
efficiency load factor l पर निर्भर करती है ।
collision resolution के लिए 2 procedure को use मे लिया जाता है ।
(1) Open Addressing:-
माना एक नये record R को key K के साथ memory table T मे add करना है
लेकिन memory address या memory location के साथ hash address पहले से भरी हुई है ।
इस प्रकार के collision को दूर करने के लिए R को first available location मे assign कर दिया जायेगा ।
इसके लिए सबसे पहले record R को search किया जायेगा इसके लिए linear search को use मे लेते है ।
इस प्रकार के collision resolution को linear probing कहा जाता है
- What is Recursion in Data Structure in Hindi ?
- कंप्यूटर क्या है
- What is Hash Table in Data Structure in Hindi
Example:-
माना एक table T मे 11 memory locations है
T[1] …… T[11] तथा file F मे 8 records है A,B,C,D,E,X,T, तथा Z जिसके hash address निम्न है
माना 8 records को table T मे उपरोक्त order के आधार पर enter कर दिया गया है ।
अब file F को memory मे निम्न प्रकार से देखा जा सकता है ।
Linear probing का main disadvantage यह है की records का cauterization हो सकता है
जब load factor > 50% हो clustering किसी भी record के average search time को increase कर देती है ।
2 chaining:-
chaining memory मे 2 tables को maintain करती है । एक table T memory मे F records को contain करती है ।
T एक additional field को maintain करता है ।जिसमे links को रखा जाता है सभी records जो tablet मे है same hash address H के द्वारा एक दूसरे से linked रहते है ।
For example: – एक data table T मे 8 records है जिनका hash address निम्न records है ।
Chaining को use मे लेकर records को memory मे निम्न प्रकार से represent किया जा सकता है ।
निवेदन:- अगर आपके लिए यह आर्टिकल useful रहा हो तो इसे अपने दोस्तों और classmates के साथ अवश्य share कीजिये, और आपके या अन्य विषयों से related कोई question हो तो नीचे कमेंट के द्वारा बताइए. thanks.