aboutsummaryrefslogtreecommitdiff
path: root/binary_search_tool/full_bisect_test/stack.c
diff options
context:
space:
mode:
Diffstat (limited to 'binary_search_tool/full_bisect_test/stack.c')
-rw-r--r--binary_search_tool/full_bisect_test/stack.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/binary_search_tool/full_bisect_test/stack.c b/binary_search_tool/full_bisect_test/stack.c
new file mode 100644
index 00000000..f8d0568f
--- /dev/null
+++ b/binary_search_tool/full_bisect_test/stack.c
@@ -0,0 +1,25 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include "bin-trees.h"
+
+tree_ptr
+pop (struct stack_struct **stack)
+{
+ if (*stack == NULL)
+ return NULL;
+ else
+ {
+ tree_ptr value = (*stack)->data;
+ (*stack) = (*stack)->next;
+ return value;
+ }
+}
+
+void
+push (struct stack_struct **stack, tree_ptr value)
+{
+ struct stack_struct *new_node = (struct stack_struct *) malloc (sizeof (struct stack_struct *));
+ new_node->data = value;
+ new_node->next = *stack;
+ *stack = new_node;
+}