MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / buildTree

Method buildTree

Trees/delete_nodes_BST.cpp:31–53  ·  view source on GitHub ↗

builds a Binary Tree taking (int) value as an argument and returns the root to the tree built.

Source from the content-addressed store, hash-verified

29
30 //builds a Binary Tree taking (int) value as an argument and returns the root to the tree built.
31 Tree* buildTree(int val)
32 {
33 if(this==nullptr)
34 {
35 Tree *temp = new Tree(val);
36 return temp;
37 }
38 else
39 {
40 Tree *temp=nullptr;
41 if(this->val>val)
42 {
43 temp=this->left->buildTree(val);
44 this->left=temp;
45 }
46 else
47 {
48 temp=this->right->buildTree(val);
49 this->right=temp;
50 }
51 return this;
52 }
53 }
54
55 //RECURSIVE DFS PREORDER
56 void preOrder()

Callers 1

mainFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected