Wednesday 18 September 2013

Hashing in detail

Hashing is a technique of saving data in key/value form. So accessing data with help of key is quite fast , it has around O(1) Time complexity which is equivalent  to constant time.
Example :
• Input ["key"] = value , accessing value with help of key.
• Hashing technique used in cache system of our computer for 
   Fast data accessing between ram & cpu ( registers ).



Basic hashing 
Storing data in key / value form in which each key is unique.
Like storing keys : "ram" , "sham" , "geeta" , "sita"  & values : there respective word length.
Input["ram"] = 3
Input["sham"] = 4
Input["geeta"] = 5
Input["sita"] = 4 , so you can see each value is stored in unique key. And now i want the value of "sita" , so instead of traversing    The whole list for key "sita" , i will just use input["sita"] & get 4 as value with one hit only from memory. I hope you are getting a bit feel of hashing , so lets dive a little more to understand how we can hash complex or say non-unique key data.

Collision resolution
A collision occurs when hashing algorithm produces an address for an insertion key & that address is already occupied . There are ways by which we can avoid collision using chain addressing i.e using linked list for storing same key data.






Basics of Tree data structure

Tree data structure simulates a  hierarchical tree structure, with root and subtrees represented by linked nodes. Some Terminology Root...