blob: f4ae62ccc45b718e7dedbc4c4b43fdb422263505 (
plain)
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
|
/**
* A struct to represent a node in a Binary Tree
*/
struct node {
int data;
struct node *left;
struct node *right;
};
typedef struct node Node;
/**
* A signature of a function pointer
* that can be used to traverse a binary tree.
*/
typedef void(Visitor)(Node* node);
/**
* The different types of traversals that the binary tree can perform
*/
enum Traversal {
INORDER = 1, // In order traversal
PREORDER = 2, // Pre order traversal
POSTORDER = 4 // Post order traversal
};
Node *initialize(int data);
void traverse(Node *node, Visitor visitor, enum Traversal traversal);
void destroy(Node *head);
void inspect(Node *head, int level);
|