欢迎来到天天文库
浏览记录
ID:38369979
大小:27.00 KB
页数:4页
时间:2019-06-11
《数据结构实验五:散列表》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、《数据结构》实验报告专业班级:学生姓名:学号:实验日期:6.8指导老师:实验五:散列表程序:#includeusingnamespacestd;typedefElemTypeArrayHashList[HashMaxsize];typedefLNode*LinkHashList[HashMaxsize];structLNode{ElemTypedata;LNode*next;};voidInitHashLish(ArrayHashList*&HT){for(inti=0;i2、voidClearHashList(ArrayHashListHT)for(inti=0;i++;i3、,intm,ElemTypeitem){intd=key%13;inttemp=d;while(HT[d].key!=NullTag){if(HT[d].key==item.key)returnd;elsed=(d+1)%m;if(d==temp)return-1;}boolDetele(ArrayHashListHT,intm,ElemType&item){intd=H(item.key,m);inttemp=d;while(HT[d].key=DeleteTag;returntrue;}elsed=(d+1)%m;if(d==temp)returnfalse;4、}returnfalse;}voidmain(){inta[16]={18,46,58,32,65,24,50,38,35,47,82,93,20,33,48,15};ArrayHashList*ht=NULL;for(inti=0;i<16;i++)Insert(ht,a[i],item)Search(ht,a[i];item)Delete(ht,a[i],item)ClearHashList(ht);}
2、voidClearHashList(ArrayHashListHT)for(inti=0;i++;i3、,intm,ElemTypeitem){intd=key%13;inttemp=d;while(HT[d].key!=NullTag){if(HT[d].key==item.key)returnd;elsed=(d+1)%m;if(d==temp)return-1;}boolDetele(ArrayHashListHT,intm,ElemType&item){intd=H(item.key,m);inttemp=d;while(HT[d].key=DeleteTag;returntrue;}elsed=(d+1)%m;if(d==temp)returnfalse;4、}returnfalse;}voidmain(){inta[16]={18,46,58,32,65,24,50,38,35,47,82,93,20,33,48,15};ArrayHashList*ht=NULL;for(inti=0;i<16;i++)Insert(ht,a[i],item)Search(ht,a[i];item)Delete(ht,a[i],item)ClearHashList(ht);}
3、,intm,ElemTypeitem){intd=key%13;inttemp=d;while(HT[d].key!=NullTag){if(HT[d].key==item.key)returnd;elsed=(d+1)%m;if(d==temp)return-1;}boolDetele(ArrayHashListHT,intm,ElemType&item){intd=H(item.key,m);inttemp=d;while(HT[d].key=DeleteTag;returntrue;}elsed=(d+1)%m;if(d==temp)returnfalse;
4、}returnfalse;}voidmain(){inta[16]={18,46,58,32,65,24,50,38,35,47,82,93,20,33,48,15};ArrayHashList*ht=NULL;for(inti=0;i<16;i++)Insert(ht,a[i],item)Search(ht,a[i];item)Delete(ht,a[i],item)ClearHashList(ht);}
此文档下载收益归作者所有