Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
LP(Multi)
//g++ 7.4.0 ////////////////////////////////////////////////////////////////////////////////LP(Multi):understanding Linear Probing in hashing(Multiplication method) //this code is created by Rezaul Hoque on September 18,2022; //contact:jewelmrh@yahoo.com;Dhaka,Bangladesh;https://rezaulhoque.wordpress.com,https://hoquestake.blogspot.com //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; ////////////////////////////////////////////////////////////////////////////// #include <iostream> #include <cmath> class LP{ int n=8; int k[8]; int v[8]; public: LP(int s[],int t[]){ for(int i=0;i<n;i++){ k[i]=s[i]; v[i]=t[i]; } } void hash(){ int tab[n]; int val[n]; for(int i=0;i<n;i++){ tab[i]= -1; val[i]=-1; } for(int i=0;i<n; i++){ int h=floor(n*fmod(k[i]*0.618,1)); if(tab[h]== -1) { tab[h]=k[i]; val[h]=v[i]; } else { for(int j=0;j<n;j++){ int q=(h+j)%n; if(tab[q]== -1) { tab[q]=k[j]; val[q]=v[j]; break; } } } } for (int i=0;i<n; i++) std::cout<<tab[i]<<" "<<val[i]<<"\n"; } }; int main(){ int a[]={700,103,107,109,111,113,115,117}; int val[]={90,32,24,51,70,30,11,87}; LP lh(a,val); lh.hash(); return 0; }
run
|
edit
|
history
|
help
0
member function pointer
Triplet sum in array
CheckSymbolBalance
First and last Occurence of an Element
adjacent_difference-30-Seconds-Of-CPP
СП КИ ЭТАП 2
https://codeforces.com/contest/449/problem/D (INCLuSION EXCLUSION principle)
pac update
Baaad1
პირამიდის ფართობი~ფინალური