aboutsummaryrefslogtreecommitdiff
path: root/binary_search_tool/full_bisect_test/build.c
diff options
context:
space:
mode:
authorZhizhou Yang <zhizhouy@google.com>2017-07-21 16:06:55 -0700
committerZhizhou Yang <zhizhouy@google.com>2017-07-21 16:10:53 -0700
commit4307f4735e9a4e3189e8d43f7493bb677a4d06ba (patch)
treebf139ee25415cecde142e95791edba3803b2452a /binary_search_tool/full_bisect_test/build.c
parent7091edfaa0ec531905b7d914e9307cd74caf02ea (diff)
parent978b96a8b02935d40e3a2c57cd033dbedd8980e9 (diff)
downloadtoolchain-utils-4307f4735e9a4e3189e8d43f7493bb677a4d06ba.tar.gz
Merge branch 'aosp/mirror-chromium-master' into update_utilsandroid-o-iot-preview-5o-iot-preview-5
Update toolchain_utils from ChromeOS side, which includes: initializing Android toolchain benchmark suite and other changes since last merging. Bug: None. Test: None. Change-Id: I9cd74f4377a8109872414636342be0b9f5df2db5
Diffstat (limited to 'binary_search_tool/full_bisect_test/build.c')
-rw-r--r--binary_search_tool/full_bisect_test/build.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/binary_search_tool/full_bisect_test/build.c b/binary_search_tool/full_bisect_test/build.c
new file mode 100644
index 00000000..ea1c8b49
--- /dev/null
+++ b/binary_search_tool/full_bisect_test/build.c
@@ -0,0 +1,23 @@
+#include <stdlib.h>
+#include "bin-trees.h"
+
+tree_ptr
+new_node (int value)
+{
+ tree_ptr node = (tree_ptr) malloc (sizeof (tree_ptr));
+ node->data = value;
+ node->left = NULL;
+ node->right = NULL;
+ return node;
+}
+
+void
+search_tree_insert (tree_ptr *root, int value)
+{
+ if (*root == NULL)
+ *root = new_node (value);
+ else if (value < (*root)->data)
+ search_tree_insert (&((*root)->left), value);
+ else if (value > (*root)->data)
+ search_tree_insert (&((*root)->right), value);
+}