diff --git a/Hashing_using_array.cpp b/Hashing_using_array.cpp new file mode 100644 index 0000000..b9468ae --- /dev/null +++ b/Hashing_using_array.cpp @@ -0,0 +1,21 @@ +// Hashing is a technique to find out the frequency of an element in an array at O(N) time complexity. +// This method uses hash array to perform hasing. +#include +using namespace std; +int main(){ + int n; //size of array + cin>>n; + int max_input=INT_MIN; + int nums[n]; //array to be hashed + for(int i=0;i>nums[i]; + max_input=max(max_input,nums[i]); + } + int hash[max_input+1]={0}; + for(int i=0;i>desired_num; + cout<<"The frequency of "< +using namespace std; +int main(){ + int n; //size of array + cin>>n; + int nums[n]; //array to be hashed + for(int i=0;i>nums[i]; + } + map hashmap; + for(int i=0;i>desired_num; + cout<<"The frequency of "<