Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <malloc.h>
- int len (char text[]) {
- int i = 0;
- while (text[++i]);
- return i;
- }
- int max (int a, int b) {
- return a > b ? a : b;
- }
- struct Node {
- char key[101];
- int height;
- struct Node *left, *right;
- };
- int height (struct Node *node) {
- return !node ? 0 : node->height;
- }
- int bFactor (struct Node *node) {
- return !node ? 0 : height(node->left) - height(node->right);
- }
- struct Node *rightRotate (struct Node *node) {
- struct Node *x = node->left;
- struct Node *y = x->right;
- x->right = node;
- node->left = y;
- node->height = max(height(node->left), height(node->right)) + 1;
- x->height = max(height(x->left), height(x->right)) + 1;
- return x;
- }
- struct Node *leftRotate (struct Node *node) {
- struct Node *x = node->right;
- struct Node *y = x->left;
- x->left = node;
- node->right = y;
- node->height = max(height(node->left), height(node->right)) + 1;
- x->height = max(height(x->left), height(x->right)) + 1;
- return x;
- }
- struct Node *insert
- int main (int argc, char **argv) {
- return 0;
- }
Add Comment
Please, Sign In to add comment