summaryrefslogtreecommitdiff
path: root/src/02/01/binary_tree.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/02/01/binary_tree.h')
-rw-r--r--src/02/01/binary_tree.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/02/01/binary_tree.h b/src/02/01/binary_tree.h
index e30b71a..f4ae62c 100644
--- a/src/02/01/binary_tree.h
+++ b/src/02/01/binary_tree.h
@@ -1,3 +1,6 @@
+/**
+ * A struct to represent a node in a Binary Tree
+ */
struct node {
int data;
struct node *left;
@@ -5,8 +8,21 @@ struct node {
};
typedef struct node Node;
+
+/**
+ * A signature of a function pointer
+ * that can be used to traverse a binary tree.
+ */
typedef void(Visitor)(Node* node);
-enum Traversal { INORDER = 1, PREORDER = 2, POSTORDER = 4 };
+
+/**
+ * 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);