 Hello everyone, my name is Nikhil Gadjum working as assistant professor in department of computer science and engineering in Walchand Institute of Technology, Solapur. In today's session we will see introduction to hashing and its comparison with linear search and binary search. This is a learning outcome at the end of this session student will be able to differentiate between linear search, binary search with hashing as a searching technique. Now in general there are three basic searching technique and those are linear search, binary search and hashing. There are many advanced searching techniques are also available but in this session we will see these three basic searching techniques in detail and we compare hashing with linear search and binary search. We will see one by one first one linear search. In linear search, a searching is carried out from first element to last element or from last element to first element or in other way we can say that searching is done from 0th index to last index or searching is done from last index to first index and if element is not present in the array at last we will come to know that element is not present inside an array. So this is an example. Suppose we want to search whether 65 is present inside this array or not. So in this example we are searching whether 65 is present inside array from 0th index to last index. So after searching at each and every index we come to know that 65 is not present inside this array. So this is a linear search. Next searching algorithm or method we call it as binary search which is advanced and efficient searching than linear search. In binary search searching is carried out on sorted array. In linear search sorted array is not compulsion but in binary search array should be a sorted one. So searching in binary search is carried out in a sorted array by dividing an array in two half parts. First we are comparing a search key with middle element. If element to be search is present at middle element we are directly returning from first iteration. If element is not present inside an array at middle position in that case we are comparing a search key with middle element. If a search key is less than middle element then we perform next searching in first middle half part. If search key or search element is more than middle element in that case we are searching in next or later or last half part of an array. So this is a binary search. Now pause the video and you can answer what is the complexity of searching of an element in linear search and binary search. So this table describes the base case, average case and worst case complexity for linear search and binary search. Base case complexity of linear search is big of 1, average case is big of n and worst case is big of n. We will see, base case means if element is present at 0th index if we are searching from first index to last index. So within first comparison we are finding element is present inside an array. So base case complexity for linear search is big of 1, average case and worst case complexity for linear search we are given as big of n. In general we are expressing complexity in terms of n or n square or log n something like that. So average case and worst case complexity of linear search is given as big of n, worst case means if element is present at last index or element is not present inside an array. So we have to compare at each and every index in worst case. But in binary search base case is big of 1 if element is present at middle position. So within first comparison, one comparison we are finding element is present inside an array. Average case and worst case complexity of binary search is given as big of log n to the base 2. So log n is more efficient than big of n so we can say that or we can conclude that binary search is more efficient searching than linear search or in other words we can say binary search takes less time for searching an element inside an array as compared to linear search. Now we will see what is hashing. Hashing is a process of indexing and retrieving an element from the data structure to provide faster way to finding an element using hash key. Now hashing is done in general so that we can search an element faster than linear search and binary search. Here hash key is the value which provides index value where to store an input data in the data structure or hash table. So hash table is just an array which maps input data to a data structure with the help of hash function. Hashing generally we can say that it is insertion and searching technique and we perform and it performs searching with constant time complexity we call it as big of 1. So hashing is more faster searching technique than linear search and binary search and its complexity, ideal complexity is given as big of 1 means we can search an element using hash key with one comparison only. So within one comparison you can say that whether an element is present inside an array or not. So within one comparison you are finding so we have to insert an element inside a data structure in particular way that it can be retrieved within a one comparison. So this is a general diagram of hashing. Key 1, key 2, key 3 are the elements which to be inserted inside an data structure we call it as hash table. So this is an hash table. So input elements or input keys are not directly inserted into a hash table. These are inputted to a hash function first. Hash function will find out one value such that where to insert this input element inside this hash table. So output of hash function will be an hash key which tells the position where to store this input element inside a hash table. So find out the answer for this question, what are the factors that may affect complexity of hashing? You can pause the video and you can answer important factor for which affect the complexity of hashing is hash function. Again input element are not inserted directly inside a hash table or data structure those are inputted first to a hash function. Hash function will return one value that value represents a location where to store that input value inside a data structure. So important point or important part of this hashing is a hash function. There are many hash functions present for generating a hash value for an input element. Now most famous example of hash function is division. Division means we are finding the remainder using a size of an array. So hash function will return a hash key for an input element where to store the input value inside a data structure. So after inserting a searching should be done with a big of one time. Within one comparisons you have to find out whether an element is present inside a data structure or not. So hash function should provide a different hash values for different input values. So that whenever we want to search it should generate a unique location whether to find out whether that element is present at particular location or not. If hash value provides same output for different values then multiple values need has to be stored at same location. So in that case we call it as collision. Collision is a special case in hashing where multiple values provide generated same hash key for different multiple values. So collision it actually reduces the complexity of hashing. The ideal complexity of hashing is given as big of one. So within one comparison you can tell that whether a particular element is present inside a hash structure or data structure or hash table. So hash function plays an important role for mapping an input element with the data structure or with the hash table. So hash table also another factor for affecting the complexity of hashing. Hash table should be a big enough so that it can accommodate all the input values inside a data structure. If hash table value are less in that case also there are less number of input values that can be stored inside a data structure or hash table. So best example for hash table is chaining we are using linked list as a data structure for storing an element. In that case there is no size restriction as linked list allocates the memory dynamically. If we are using array as a data structure for hashing in that case a size of array should be enough so that it can accommodate all the input values inside it. These are the references I have used for creation of this video. Thank you.