w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Common node structure for binary search tree and AVL tree

This might be Helpful for You

#include<stdio.h>
#include<malloc.h>

struct CommonNode{
int data;
struct CommonNode *left, *right;
};

typedef struct CommonNode node;

struct bsTree{
node *nodePtr;
};

typedef struct bsTree bst;

struct AVLTree{
node *nodePtr;
int balanceFactor;
};

typedef struct AVLTree avl;


int main()
{
avl *p;
p = (struct AVLTree*)malloc(sizeof(struct AVLTree));
p->nodePtr = (node*)malloc(sizeof(node));
p->nodePtr->data = 20;
printf("The data value is %d
",p->nodePtr->data);
return 0;
}


OUTPUT:
The data value is 20




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.