- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1862 Articles for Data Structure
3K+ Views
In this section we will see what is Double Hashing technique in open addressing scheme. There is an ordinary hash function h´(x) : U → {0, 1, . . ., m – 1}. In open addressing scheme, the actual hash function h(x) is taking the ordinary hash function h’(x) when the space is not empty, then perform another hash function to get some space to insert.$$h_{1}(x)=x\:mod\:m$$$$h_{2}(x)=x\:mod\:m^{\prime}$$$$h(x, i)=(h^{1}(x)+ih^{2})\:mod\:m$$The value of i = 0, 1, . . ., m – 1. So we start from i = 0, and increase this until we get one free space. So initially when i = ... Read More
6K+ Views
In this section we will see what is quadratic probing technique in open addressing scheme. There is an ordinary hash function h’(x) : U → {0, 1, . . ., m – 1}. In open addressing scheme, the actual hash function h(x) is taking the ordinary hash function h’(x) and attach some another part with it to make one quadratic equation.h´ = (𝑥) = 𝑥 𝑚𝑜𝑑 𝑚ℎ(𝑥, 𝑖) = (ℎ´(𝑥) + 𝑖2)𝑚𝑜𝑑 𝑚We can put some other quadratic equations also using some constantsThe value of i = 0, 1, . . ., m – 1. So we start from i ... Read More
7K+ Views
In this section we will see what is linear probing technique in open addressing scheme. There is an ordinary hash function h´(x) : U → {0, 1, . . ., m – 1}. In open addressing scheme, the actual hash function h(x) is taking the ordinary hash function h’(x) and attach some another part with it to make one linear equation.h´(𝑥) = 𝑥 𝑚𝑜𝑑 𝑚ℎ(𝑥, 𝑖) = (ℎ´(𝑥) + 𝑖)𝑚𝑜𝑑 𝑚The value of i| = 0, 1, . . ., m – 1. So we start from i = 0, and increase this until we get one freespace. So initially ... Read More
2K+ Views
In this section we will see what is the hashing by open addressing. The open addressing is another technique for collision resolution. Unlike chaining, it does not insert elements to some other data-structures. It inserts the data into the hash table itself. The size of the hash table should be larger than the number of keys.There are three different popular methods for open addressing techniques. These methods are −Linear ProbingQuadratic ProbingDouble HashingIn this technique, we use a hash function like other hash techniques. If the place is free, then insert the element into that location. Now if that place is ... Read More
6K+ Views
In this section we will see what is the hashing with chaining. The Chaining is one collision resolution technique. We cannot avoid collision, but we can try to reduce the collision, and try to store multiple elements for same hash value.this technique suppose our hash function h(x) ranging from 0 to 6. So for more than 7 elements, there must be some elements, that will be places inside the same room. For that we will create a list to store them accordingly. In each time we will add at the beginning of the list to perform insertion in O(1) timeLet ... Read More
606 Views
For any hash function we can say that if the table size m is much smaller than universe size u, then for any hash function h, there is some large subset of U that has the same hash value.To get rid of this problem, we need a set of hash functions, from which we can choose any one that works well for S. If most of the hash functions are better for S, we can choose random hash functionSuppose ℌ be a set of hash functions. We can say ℌ is universal if, for each x, y ∈ U, the ... Read More
760 Views
Here we will discuss about the hashing with multiplication method. For this we use the hash function −ℎ(𝑥) = ⌊𝑚𝑥𝐴⌋ 𝑚𝑜𝑑 𝑚Here A is a real-valued constant. The advantage of this method is that the value of m is not so critical. We can take m as power of 2 also. Although any value of A gives the hash function, but some values of A are better than others.According to Knuth, we can use the golden ratio for A, So A will be$$A=\frac{\sqrt5-1}{2}=0.61803398$$Of course, no matter what value is chosen for A. The pigeonhole principle implies that if u ≥ ... Read More
421 Views
Here we will discuss about the hashing with division. For this we use the hash function −ℎ(𝑥) = 𝑥 𝑚𝑜𝑑 𝑚To use this hash function we maintain an array A[0, … m – 1]. Where each element of the array is a pointer to the head of the linked list. The linked list Li is pointed to array element A[i] holds all elements x such that h(x) = i. This technique is known as hashing by chaining.In such hash table, if we want to increase an element x, this will take O(1) time. we compute the index i = h(x). ... Read More
248 Views
Here we will discuss about the Hash tables with the integer keys. Here the key values 𝑥 comes from universe 𝑈 such that 𝑈 = {0, 1, … , 𝑢 – 2, 𝑢 – 1}. A hash function is ℎ. The domain of this hash function is 𝑈. The range is in the set {0, 1, … , 𝑚 – 1}, and 𝑚 ≤ 𝑢.A hash function h is said to be a perfect hash function for a set 𝑆 ⊆ 𝑈 if for every 𝑥 ∈ 𝑆, ℎ(𝑥) is unique. A perfect hash function ℎ for 𝑆 is minimal ... Read More
1K+ Views
Here we will see how to delete elements from binary max heap data structures. Suppose the initial tree is like below −Deletion Algorithmdelete(heap, n) − Begin if heap is empty, then exit else item := heap[1] last := heap[n] n := n – 1 for i := 1, j := 2, j = heap[j], then break heap[i] := heap[j] done end if heap[i] := last EndExampleSuppose we want to delete 30 from the final heap −