MCPcopy Create free account
hub / github.com/anupam-kumar-krishnan/Competitive_Programming / rInsert

Method rInsert

All Data Structures/TREE/BST.cpp:116–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114}
115
116Node *BST::rInsert(Node *p, int key)
117{
118 Node *t;
119 if (p == nullptr)
120 {
121 t = new Node;
122 t->data = key;
123 t->lchild = nullptr;
124 t->rchild = nullptr;
125 return t;
126 }
127
128 if (key < p->data)
129 {
130 p->lchild = rInsert(p->lchild, key);
131 }
132 else if (key > p->data)
133 {
134 p->rchild = rInsert(p->rchild, key);
135 }
136 return p; // key == p->data?
137}
138
139Node *BST::rSearch(Node *p, int key)
140{

Callers 1

mainFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected