Sherwood算法消除最壞實(shí)例,以達(dá)到對(duì)任何實(shí)例都能有好的性能的效果
文件:
rd_list.c --> create a random sequence of n integers not equal to each other
list.c --> create a descending sequence of n integers not equal to each other
Sherwood.c --> 就是該算法,靜態(tài)鏈表的長(zhǎng)度默認(rèn)設(shè)為1000,可在宏定義處修改
用法:
gcc -o Sherwood Sherwood.c
gcc -o rd_list rd_list.c
gcc -o list list.c
./rd_list s.txt 1000 產(chǎn)生一個(gè)長(zhǎng)度為1000的互不相等的隨機(jī)序列,保存在s.txt中
./list s1.txt 1000 產(chǎn)生一個(gè)長(zhǎng)度為1000的互不相等的降序序列,保存雜s1.txt中
./Sherwood s1.txt 運(yùn)行算法,比較其中的4個(gè)算法的性能差異
標(biāo)簽:
Sherwood
算法
上傳時(shí)間:
2016-01-20
上傳用戶:ainimao