資源簡介
數據結構與算法分析:C語言描述(第2版) 下載 附源碼及答案
代碼片段和文件信息
#include?“aatree.h“
#include?
#include?“fatal.h“
/*?START:?fig12_27.txt?*/
????????????/*?Returned?for?failures?*/
????????Position?NullNode?=?NULL;??/*?Needs?more?initialization?*/
????????struct?AANode
????????{
????????????ElementType?Element;
????????????AATree??????Left;
????????????AATree??????Right;
????????????int?????????Level;
????????};
????????AATree
????????Initialize(?void?)
????????{
????????????if(?NullNode?==?NULL?)
????????????{
????????????????NullNode?=?malloc(?sizeof(?struct?AANode?)?);
????????????????if(?NullNode?==?NULL?)
????????????????????FatalError(?“Out?of?space!!!“?);
????????????????NullNode->Left?=?NullNode->Right?=?NullNode;
????????????????NullNode->Level?=?0;
????????????}
????????????return?NullNode;
????????}
/*?END?*/
????????AATree
????????MakeEmpty(?AATree?T?)
????????{
????????????if(?T?!=?NullNode?)
????????????{
????????????????MakeEmpty(?T->Left?);
????????????????MakeEmpty(?T->Right?);
????????????????free(?T?);
????????????}
????????????return?NullNode;
????????}
????????Position
????????Find(?ElementType?X?AATree?T?)
????????{
????????????if(?T?==?NullNode?)
????????????????return?NullNode;
????????????if(?X?Element?)
????????????????return?Find(?X?T->Left?);
????????????else
????????????if(?X?>?T->Element?)
????????????????return?Find(?X?T->Right?);
????????????else
????????????????return?T;
????????}
????????Position
????????FindMin(?AATree?T?)
????????{
????????????if(?T?==?NullNode?)
????????????????return?NullNode;
????????????else
????????????if(?T->Left?==?NullNode?)
????????????????return?T;
????????????else
????????????????return?FindMin(?T->Left?);
????????}
????????Position
????????FindMax(?AATree?T?)
????????{
????????????if(?T?!=?NullNode?)
????????????????while(?T->Right?!=?NullNode?)
????????????????????T?=?T->Right;
????????????return?T;
????????}
????????/*?This?function?can?be?called?only?if?K2?has?a?left?child?*/
????????/*?Perform?a?rotate?between?a?node?(K2)?and?its?left?child?*/
????????/*?Update?heights?then?return?new?root?*/
????????static?Position
????????SingleRotateWithLeft(?Position?K2?)
????????{
????????????Position?K1;
????????????K1?=?K2->Left;
????????????K2->Left?=?K1->Right;
????????????K1->Right?=?K2;
????????????return?K1;??/*?New?root?*/
????????}
????????/*?This?function?can?be?called?only?if?K1?has?a?right?child?*/
????????/*?Perform?a?rotate?between?a?node?(K1)?and?its?right?child?*/
????????/*?Update?heights?then?return?new?root?*/
????????static?Position
????????SingleRotateWithRight(?Position?K1?)
????????{
????????????Position?K2;
????????????K2?=?K1->Right;
????????????K1->Right?=?K2->Left;
????????????K2->Left?=?K1;
????????????return?K2;??/*?New?root?*/
????????}
/*?START:?fig12_29.txt?*/
????????/*?If?T‘s?left?child?is?on?the?same?level?as?T?*/
????????/*?perform?a?rotation?*/
????????AATree
????????Skew(?AATree?T?)
????????{
????????????if(?T->Left->Level?==?T->Level?)
????????????????T?=?SingleRotateWithLeft(?T
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-09-11?10:22??習題答案\
?????文件????????4112??2014-09-04?22:11??習題答案\ch00.pdf
?????文件???????11708??2014-09-04?22:11??習題答案\ch01.pdf
?????文件???????14778??2014-09-04?22:11??習題答案\ch02.pdf
?????文件???????15330??2014-09-04?22:11??習題答案\ch03.pdf
?????文件???????29060??2014-09-04?22:11??習題答案\ch04.pdf
?????文件???????13390??2014-09-04?22:11??習題答案\ch05.pdf
?????文件???????32039??2014-09-04?22:11??習題答案\ch06.pdf
?????文件???????22231??2014-09-04?22:11??習題答案\ch07.pdf
?????文件???????14724??2014-09-04?22:11??習題答案\ch08.pdf
?????文件???????42865??2014-09-04?22:11??習題答案\ch09.pdf
?????文件???????45488??2014-09-04?22:11??習題答案\ch10.pdf
?????文件???????13333??2014-09-04?22:11??習題答案\ch11.pdf
?????文件????????4435??2014-09-04?22:11??習題答案\ch12.pdf
?????文件????40795325??2014-09-04?22:11??數據結構與算法分析:C語言描述(第2版).pdf
?????目錄???????????0??2015-01-15?09:15??源碼\
?????文件????????6181??2015-01-15?09:14??源碼\aatree.c
?????文件?????????669??2015-01-15?09:14??源碼\aatree.h
?????文件????????5593??2015-01-15?09:14??源碼\avltree.c
?????文件?????????583??2015-01-15?09:14??源碼\avltree.h
?????文件????????3364??2015-01-15?09:14??源碼\binheap.c
?????文件?????????588??2015-01-15?09:14??源碼\binheap.h
?????文件????????6727??2015-01-15?09:14??源碼\binomial.c
?????文件?????????762??2015-01-15?09:14??源碼\binomial.h
?????文件????????4474??2015-01-15?09:14??源碼\cursor.c
?????文件?????????890??2015-01-15?09:14??源碼\cursor.h
?????文件????????2564??2015-01-15?09:14??源碼\disjsets.c
?????文件????????4737??2015-01-15?09:14??源碼\dsl.c
?????文件?????????701??2015-01-15?09:14??源碼\dsl.h
?????文件?????????156??2015-01-15?09:14??源碼\fatal.h
?????文件?????????848??2015-01-15?09:14??源碼\fig10_38.c
............此處省略60個文件信息
- 上一篇:鄭莉《C++語言程序設計(第4版)》帶書簽
- 下一篇:MFC實現FTP客戶端
評論
共有 條評論