 Hello everyone, my name is Nikhil Gadjum working as assistant professor in Walsh and Institute of Technology, Solapur in CSC department. In today's video we will see hashing without collision and its implementation program in C language. This is a learning outcome at the end of this video and at the end of this session student will be able to find out hash key for a given input number using appropriate hash function. Just revise the thing, this is a hashing general diagram where key is an input number, it is supplied as an input to hash function, there are various hash functions we have seen in earlier video. This hash function will give an output as a hash value, this hash value is nothing but a position where to store this key or input number inside this hash table. This is a general diagram of hashing, now what is collision, again if we insert an element and it hashes with the same value which is already present in the hash table, in that case that situation we call it as a collision, means two input number provides or generates same hash key by the hash function, in that case we call it as a collision. Just see an example, suppose we have taken an integer of size 10 as a hash table and we have used division method as a hash function, again division method means you are using a function mod size and suppose we want to insert a following elements inside a hash table, the elements are 11, 22, 33, 55 and 42, so one by one suppose first number is 11, 11 mod 10 is 1, so 11 is inserted at index 1, next number is 22, 22 mod 10 is 2, so 22 is inserted at index 2, next number is 33, 33 will be inserted at index 3, 55 will be inserted at index 5 and next number is 42, now 42 mod 10 is 2, so 42 should be stored at index 2 but 22 is already present at index 2, so we cannot insert 42 at index 2 because of 22 is already present, now this situation we call it as collision, now you can pause the video and you can answer what is the minimum and maximum number of elements that can be stored inside an array of size 1000 using division method and there is no collision, you can pause the video and you can answer, so answer minimum one number can be stored, so starting number is 1 and maximum 1000 elements can be stored inside an array of size 1000 and without collision, so all indices are filled with one of the value, so maximum 1000 elements can be stored, now we will see a program for this, this is an online gdb site where you can write a program and you can compile in any languages, there are multiple compilers provider here, so I will see choose compiler at c language, I will write a code for hashing without collision, so this is hash include stdo.h, I will write three functions, one for insert, one for display and one for searching, again hashing where searching is done in one comparison, so this int a of 10, this is my hash table and int size where size denotes total number of elements user wants to insert, so this is printf, enter total number of elements you want to insert is canf, this is %d, this is the address of size, now we will call a first insert function, then display function and then search function, so three function I am using, this is first one void insert, x one void display and last one void search, now we will start implementing insert function, user wants to insert this size number of elements inside a hash table a, so I will declare one index as an integer value and i, so we will use for i equal to 0 i less than size i plus plus, this is canf %d, this is element in an extra variable I am using, now we will find index using hash function as element mod 10, 10 by 10, 10 is the size of an array, so whatever element entered by the user, we will find out the index where to store that element inside an array of a having size 10, so first I will calculate index and I will store a of index is equal to element, this is an hashing, I am inserting each value entered by the user inside and hash table a, I will display all these things i, this is printf, this is %d, a of i, this is my display function and last one is my search, I will check whether my insert function and display function are working correctly or not, this is run button, click on run, this is an console, suppose I want to insert 5 elements, those elements are 11, 22, 33, 44 and suppose 55, just a second this is 10, I will run again, so to 5 elements those are 11, 22, 33, 44 and 55, so this is my hash table, so 11 is stored at index 1, 22 is stored at index 2, 33 is stored at index 3, 44 is stored at index 4 and 55 is stored at index 5, so this is one part of hashing where you are inserting an input element at particular location using hash function, now next part is searching, suppose int s and i, I am asking user what element he want to search, printf enter element you want to search, so this is my scanf %d, s, first I will calculate index where to search this s using hash function division, so s mod 10, so I will calculate the index of s, s is nothing but an element which user want to search inside and hash table, so I am searching now if a of index is double equal to s, I am printing printf element found else printf element not present, I will run this, so total number of elements you want to insert 5, suppose I am using same example 11, 22, 33, 44 and 55, this is an hash table after inserting those values, now enter element you want to search, suppose 22 I want to search whether that is present inside and hash table or not, so answer I got is element found, so importance of this hashing is, searching is done in one comparison, so this is an comparison, so within one comparison I am telling that whether that element is present or not, this is an importance of hashing, so user want to search 22 whether 22 is present inside hash table or not, first I have calculated index of 22 using modulus function, so index I got is 2, so I am directly checking whether a of 2 is double equal to 22 or not, means 22 must be present at a of 2, if it is not present I am not checking remaining indexes, I am directly printing element is not present otherwise element is present, so this is an importance of hashing, these are the references I have used for creation of this video, thank you.