Sherwood算法消除最壞實例,以達到對任何實例都能有好的性能的效果
文件:
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 --> 就是該算法,靜態鏈表的長度默認設為1000,可在宏定義處修改
用法:
gcc -o sherwood sherwood.c
gcc -o rd_list rd_list.c
gcc -o list list.c
./rd_list s.txt 1000 產生一個長度為1000的互不相等的隨機序列,保存在s.txt中
./list s1.txt 1000 產生一個長度為1000的互不相等的降序序列,保存雜s1.txt中
./sherwood s1.txt 運行算法,比較其中的4個算法的性能差異
Yacc說明及使用文檔
yacc(Yet Another Compiler Compiler),是Unix/Linux上一個用來生成編譯器的編譯器(編譯器代碼生成器)。yacc生成的編譯器主要是用C語言寫成的語法解析器(Parser),需要與詞法解析器Lex一起使用,再把兩部份產生出來的C程序一併編譯。yacc本來只在Unix系統上才有,但現時已普遍移植往Windows及其他平臺。