// ds06.cpp : defines the entry point for the console application.
//#include "stdafx.h"
#include
#include
using namespace std;
typedef int elemtype;
typedef struct sstable;
//構造乙個含n個資料元素的靜態查詢表st
void create_st(sstable &st, int n)
}//輸出靜態查詢表
void output_st(sstable st)
cout << endl;
}/*在有序表中折半查詢等於key的資料元素。若找到,則函式
值為該元素在表中的位置,否則為0.*/
int search_bin(sstable &st, elemtype key) //while
return 0; //順序表中不存在待查元素
}//展示給使用者
void show(sstable &st)
}int _tmain(int argc, _tchar* argv)
* 06-2_hash查詢.cpp -- hash查詢的相關操作
* 對hash查詢的每個基本操作都用單獨的函式來實現
* 水上飄 2023年寫
// ds06_2.cpp : 定義控制台應用程式的入口點。
//#include "stdafx.h"
#include
#include
#include
using namespace std;
enum result ;
typedef int elemtype; //元素型別
typedef structhashtable;
//初始化雜湊表
void inithash(hashtable &h, int n)
}//計算雜湊位址
int hash(elemtype k, int sizeindex)
//在雜湊表中查詢元素k,c記錄衝突次數
int searchhash(hashtable &h, elemtype k, int &haaddr, int &c)
}//while
if (k == h.elem[haaddr])//if
else//else
}/*查詢不成功時插入資料元素e到雜湊表中,
若衝突次數過大,則重建雜湊表*/
int inserthash(hashtable &h, elemtype e)//if
else if (collision < h.sizeindex - 2)//else if
else //else
}//刪除雜湊表中某乙個關鍵字
int deletehash(hashtable &h, elemtype e)//for
if(p == 0)
return unsuccess;
else return success;
}//列印出雜湊表
void printhash(hashtable h)//for
cout << endl;
}//執行各個函式
void performance(hashtable &h)//while
printhash(h);//輸出
int del = 1;
cout << "輸入要刪除的元素,否則輸入『0』:";
cin >> del;
while(del != 0)//while
}int _tmain(int argc, _tchar* argv)
{ hashtable h;
performance(h);
資料結構查詢排序實驗
實驗五 查詢和排序 班級 b09513 學號 200940 姓名 一 實驗目的 1 掌握查詢的不同方法,並能用高階語言實現查詢演算法。2 熟練掌握順序表和有序表的順序查詢和二分查詢方法。3 掌握排序的不同方法,並能用高階語言實現排序演算法。4 熟練掌握順序表的選擇排序 氣泡排序和直接插入排序演算法的...
資料結構實驗報告查詢演算法
資料結構 第八次實驗報告 1 實驗內容 1 有序表的二分查詢 建立有序表,然後進行二分查詢 2 二叉排序樹的查詢 建立二叉排序樹,然後查詢 2 需求分析 二分查詢的基本思想是將n個元素分成大致相等的兩部分,取a n 2 與x做比較,如果x a n 2 則找到x,演算法中止 如果xa n 2 則只要在...
資料結構實驗報告五,查詢與排序
實驗六查詢與排序 一 實驗目的 1 理解掌握查詢與排序在計算機中的各種實現方法。2 學會針對所給問題選用最適合的演算法。3 熟練掌握常用排序演算法在順序表上的實現。二 實驗要求 掌握利用常用的查詢排序演算法的思想來解決一般問題的方法和技巧,進行演算法分析並寫出實習報告。三 實驗內容及分析 設計乙個學...