Skip to main content

Posts

Showing posts with the label code implementation

AVL tree and other homeworks

AVL Tree: #include<stdio.h> #include<stdlib.h> // An AVL tree node struct Node {     int key;     struct Node *left;     struct Node *right;     int height; }; int max(int a, int b); // A utility function to get the height of the tree int height(struct Node *N) {     if (N == NULL)         return 0;     return N->height; } // A utility function to get maximum of two integers int max(int a, int b) {     return (a > b)? a : b; } /* Helper function that allocates a new node with the given key and     NULL left and right pointers. */ struct Node* newNode(int key) {     struct Node* node = (struct Node*)                         malloc(sizeof(struct Node));     node->key   = key;     node->left   = NULL;     node...