Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Depth of Bin tree
//Title of this code #include <iostream> using namespace std; struct BinTree { int data; BinTree *left; BinTree *right; BinTree(int d, BinTree* l, BinTree* r): data(d), left(l), right(r) {} }; int depth(BinTree* root, int d) { if (!root) return d; return max(depth(root->left, d + 1), depth(root->right, d + 1)); } int main() { BinTree *j = new BinTree(9, NULL, NULL); BinTree *h = new BinTree(8, NULL, NULL); BinTree *g = new BinTree(7, NULL, NULL); BinTree *f = new BinTree(6, j, h); BinTree *e = new BinTree(5, NULL, NULL); BinTree *d = new BinTree(4, NULL, NULL); BinTree *c = new BinTree(3, f, g); BinTree *b = new BinTree(2, d, e); BinTree *root = new BinTree(1, b, c); cout << depth(root, 0); }
run
|
edit
|
history
|
help
0
-fno-elide-constructors
Segmented Sieve
Updated Linked Lists - 5/10/2017 V3.0
break.cpp
segmentedSieveR
Wuninitialized
HashRK
Discounting Future Stream
test
next permutation leetcode