I need to make a function to count the amount of leafes of a binary tree and prints the highest and lowest value, for this homework I can't use recursivity so I'm struggling to figure out how to do it. The structure is:
typedef struct node {
int value;
struct node *left;
struct node *right;
} Node ;
To insert a node I created a function
void insert(Node** tree, int value){
if(*tree== NULL){
*tree= createNode(value);
} else {
int sValue= (*tree)->value;
if(value < sValue){
insert(&(*tree)->left, value);
} else {
insert(&(*tree)->right, value);
}
}
}
Node* createNode(int value){
Node* newNode= (Node*)malloc(sizeof(Node));
newNode->value= value;
newNode->left= NULL;
newNode->left= NULL;
return newNode;
}