We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f9e6bef commit 513b140Copy full SHA for 513b140
Data Structures/Trees/Diameter_Binary_Tree.cpp
@@ -56,21 +56,27 @@ int main()
56
root->left->left=newnode(9);
57
root->right=newnode(1);
58
root->left->right=newnode(6);
59
+ root->left->right->left=newnode(7);
60
// printing the final value
- cout<<"Diameter"<<final_diameter(root);
61
+ cout<<"Diameter:"<<final_diameter(root);
62
return 0;
63
}
64
65
/*
66
OUTPUT
67
68
5
- / \ the longest path is from the node conatining value '4' to node containing
69
- 3 1 value '1'.
+ / \
70
+ 3 1
71
/ \
72
9 6
-
73
- Diameter:4
74
+ /
+ 7
75
+
76
+ Diameter:5
77
78
+ the longest path is from the node conatining value '7'
79
+ to node containing value '1'.
80
81
82
*/
0 commit comments