查找、排序综合实验(8)

时间:2025-04-21

对记录序列(查找表):{55,13,23,72,109,67,2,78,13}分别实现如下操作:1)顺序查找;2)分别使用直接插入排序、冒泡排序、快速排序对原纪录序列进行排序(暂时人工排序);3)对排好序的纪录序列表进行折半查找;4)利用原纪录序列建立一颗二叉排序树,并在其上实现特定关键字值结点的查找;5)按照“除留余数法”哈希构造函数和线性探测再散列的冲突处理方法创建表长为m=11的哈希表

数据结构

》实验报告

-7-

void insertbst(bstree *bst,int k) { bstree s; if(*bst==NULL)

{ s=(bstnode*)malloc(sizeof(bstnode)); s->key=k; s->lchild=NULL; s->rchild=NULL; *bst=s; } else if(k<(*bst)->key) insertbst(&((*bst)->lchild),k); else if(k>(*bst)->key) insertbst(&((*bst)->rchild),k); } void creatbstree(bstree *bst) { int k; *bst=NULL; cout<<"输入元素:"<<endl; cin>>k; while(k!=0) { insertbst(bst,k); cout<<"输入元素:"<<endl; cin>>k; } } //二叉树查找 int searchbst(bstree bst,int k) { if(!bst)return NULL; else if(bst->key==k) { cout<<"输出特定元素:"<<bst->key<<endl; return 1; } else if(k<bst->key) searchbst(bst->lchild,k); else searchbst(bst->rchild,k); return 0; }

查找、排序综合实验(8).doc 将本文的Word文档下载到电脑

精彩图片

热门精选

大家正在看

× 游客快捷下载通道(下载后可以自由复制和排版)

限时特价:7 元/份 原价:20元

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219