AVLTree Class
Lesson 4 of 16 in Coddy's AVL Tree - Data Structures Series #10 course.
The AVLTree class wraps everything together. It holds a single field: root, a pointer to the top Node of the tree (or null when the tree is empty).
Every method you write from here on hangs off this class and starts, directly or indirectly, from root.
Challenge
BeginnerWrite a class AVLTree with a constructor that sets root to null.
Try it yourself
#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;
}
All lessons in AVL Tree - Data Structures Series #10
2AVL Tree Project
Node ClassAVLTree Class