Driver program to test above functions
| 69 | |
| 70 | // Driver program to test above functions |
| 71 | int main() |
| 72 | { |
| 73 | // Let us create the Binary Tree shown in above diagram. |
| 74 | Node * root = newNode(1); |
| 75 | root->left = newNode(2); |
| 76 | root->right = newNode(3); |
| 77 | root->left->left = newNode(4); |
| 78 | root->left->right = newNode(5); |
| 79 | root->right->left = newNode(6); |
| 80 | root->right->right = newNode(7); |
| 81 | cout << "LCA(4, 5) = " << findLCA(root, 4, 5); |
| 82 | cout << "\nLCA(4, 6) = " << findLCA(root, 4, 6); |
| 83 | cout << "\nLCA(3, 4) = " << findLCA(root, 3, 4); |
| 84 | cout << "\nLCA(2, 4) = " << findLCA(root, 2, 4); |
| 85 | return 0; |
| 86 | } |
| 87 | |
| 88 | |
| 89 | /* |