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

Function main

CPP/graph_tree/LCA_Binary-tree.cpp:71–86  ·  view source on GitHub ↗

Driver program to test above functions

Source from the content-addressed store, hash-verified

69
70// Driver program to test above functions
71int 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/*

Callers

nothing calls this directly

Calls 2

findLCAFunction · 0.85
newNodeFunction · 0.70

Tested by

no test coverage detected