-
Notifications
You must be signed in to change notification settings - Fork 0
/
BinaryTreeNode.h
30 lines (28 loc) · 981 Bytes
/
BinaryTreeNode.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once
#include "MathLibrary.h"
#include <stdlib.h>
#ifndef __BinaryTreeNode
#define __BinaryTreeNode
typedef struct BinaryTreeNode
{
void* data;
struct BinaryTreeNode* right;
struct BinaryTreeNode* left;
}BinaryTreeNode;
#endif // !__BinaryTreeNode
//Init the root of binary tree node
void MakeBinaryTree(BinaryTreeNode**, void*);
//Creates right node
void SetRightBinaryTree(BinaryTreeNode*, void*);
//Creates left node
void SetLeftBinaryTreeNode(BinaryTreeNode*, void*);
//Retruns true if givven node leaf(no childs)
BOOL IsLeafBinaryTreeNode(BinaryTreeNode*);
//Recursive method that counts amount of nodes in tree
int HowManyNodesBinaryTreeNode(BinaryTreeNode*);
//Recursive method that counts amount of leaf nodes in tree
int HowManyLeafsBinaryTreeNode(BinaryTreeNode*);
//Recursive method that returns the node with givven value
BinaryTreeNode* FindNode(BinaryTreeNode*, void*);
// Returns tree height
int FindHeight(BinaryTreeNode*);