summaryrefslogtreecommitdiff
path: root/src/02/01/binary_tree.h
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-08-15 18:04:31 -0600
committermo khan <mo.khan@gmail.com>2020-08-15 18:04:31 -0600
commitfddc2c7d930ac8aff78f15f30d832ddeba4e1057 (patch)
treed080bb0baa8530e58d717c2b840a62c7ddc1263c /src/02/01/binary_tree.h
parent3d811c69e67cff7114cbebf3c3971f6470fd6062 (diff)
Document code for the marks
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);