From e015ca300a42cfa122c7cc00cb60082b4ea54c8a Mon Sep 17 00:00:00 2001 From: shreyasingh28 <44510510+shreyasingh28@users.noreply.github.com> Date: Mon, 7 Oct 2019 11:24:17 +0530 Subject: [PATCH] Created algo for treap tree --- Treap tree Algo | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Treap tree Algo diff --git a/Treap tree Algo b/Treap tree Algo new file mode 100644 index 0000000..fef1e8c --- /dev/null +++ b/Treap tree Algo @@ -0,0 +1,14 @@ +// C function to search a given key in a given BST +TreapNode* search(TreapNode* root, int key) +{ + // Base Cases: root is null or key is present at root + if (root == NULL || root->key == key) + return root; + + // Key is greater than root's key + if (root->key < key) + return search(root->right, key); + + // Key is smaller than root's key + return search(root->left, key); +}