diff options
author | Caroline Tice <cmtice@google.com> | 2017-02-06 14:54:28 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-02-14 12:35:43 -0800 |
commit | 1cc48481a2ca530bab04999da78eddc8a1b98adb (patch) | |
tree | 2237f62191bb6be08229d08f32d64ffdd357073d /binary_search_tool/full_bisect_test/inorder_norecurse.c.bad | |
parent | 058aae85dcfb12049ef90137915ec7e981288569 (diff) | |
download | toolchain-utils-1cc48481a2ca530bab04999da78eddc8a1b98adb.tar.gz |
[binary search tool] Add bisecting tests.
Add real bisection testing, for use with or without compiler wrapper
script.
BUG=https://b.corp.google.com/issues/34888940
TEST=Tested wtih & without the compiler wrapper in my source tree.
Change-Id: I72329b458b5c93f8e7f03f9970c755018390cc3c
Reviewed-on: https://chromium-review.googlesource.com/438666
Commit-Ready: Caroline Tice <cmtice@chromium.org>
Tested-by: Caroline Tice <cmtice@chromium.org>
Reviewed-by: Yunlian Jiang <yunlian@chromium.org>
Diffstat (limited to 'binary_search_tool/full_bisect_test/inorder_norecurse.c.bad')
-rw-r--r-- | binary_search_tool/full_bisect_test/inorder_norecurse.c.bad | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/binary_search_tool/full_bisect_test/inorder_norecurse.c.bad b/binary_search_tool/full_bisect_test/inorder_norecurse.c.bad new file mode 100644 index 00000000..27f0bb16 --- /dev/null +++ b/binary_search_tool/full_bisect_test/inorder_norecurse.c.bad @@ -0,0 +1,42 @@ +#include <stdlib.h> +#include <stdio.h> +#include "bin-trees.h" + +static void +real_in_order_traverse_no_recurse (tree_ptr root) +{ + struct stack_struct *stack = NULL; + tree_ptr current= root; + int going_left = 1; /* boolean variable */ + while (current != NULL) + { + if ((current->left != NULL) && going_left) + { + push (&stack, current); + current = current->left; + } + + printf ("%d ", current->data); + if (current->right) + { + current = current->right; + going_left = 1; + } + else if (stack != NULL) + { + current = pop(&stack); + going_left = 0; + } + else + current = NULL; + } +} + +void +in_order_traverse_no_recurse (tree_ptr root) +{ + printf ("in-order traversal, without recursion: \n"); + real_in_order_traverse_no_recurse (root); + printf ("\n"); + return; +} |