AVLTree 类
Coddy AVL 树:数据结构系列 #10 课程的第 4 课,共 16 课。
AVLTree 类把所有内容整合在一起。它包含一个字段:root,这是指向树顶端 Node 的指针(如果树为空,则为 null)。
从这里开始,你编写的每个方法都属于这个类,并且直接或间接地从 root 开始。
挑战
入门编写一个类 AVLTree,并在构造函数中将 root 设置为 null。
亲手试试
#include <stdio.h>
#include <string.h>
#include "avltree.h"
int main(void) {
AVLTree* tree = AVLTree_create();
char line[256];
while (fgets(line, sizeof(line), stdin) != NULL) {
line[strcspn(line, "\r\n")] = '\0';
if (strcmp(line, "empty") == 0) {
if (tree->root == NULL) {
printf("true\n");
}
if (tree->root != NULL) {
printf("false\n");
}
}
}
return 0;
}
AVL 树:数据结构系列 #10中的所有课
自己练习: C 在线编译器