std::vector<int> adj[MAX];
29std::vector<bool> visited;
35 for(
intv : adj[u]) {
40child_height = std::max(child_height,
dp[v] + 1);
44 dp[u] = child_height;
50std::cout <<
"Enter number of nodes of the tree : "<< std::endl;
51std::cin >> number_of_nodes;
56std::cout <<
"Enter edges of the tree : "<< std::endl;
57 for(
inti = 0; i < number_of_nodes - 1; i++) {
64visited.assign(number_of_nodes + 1,
false);
66 dp.assign(number_of_nodes + 1, 0);
69std::cout <<
"Height of the Tree : "<<
dp[1] << std::endl;
int main()
Main function.
Functions for Depth First Search algorithm.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4