A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/de/d77/tree__height_8cpp_source.html below:

TheAlgorithms/C++: dynamic_programming/tree_height.cpp Source File

28

std::vector<int> adj[MAX];

29

std::vector<bool> visited;

35 for

(

int

v : adj[u]) {

40

child_height = std::max(child_height,

dp

[v] + 1);

44 dp

[u] = child_height;

50

std::cout <<

"Enter number of nodes of the tree : "

<< std::endl;

51

std::cin >> number_of_nodes;

56

std::cout <<

"Enter edges of the tree : "

<< std::endl;

57 for

(

int

i = 0; i < number_of_nodes - 1; i++) {

64

visited.assign(number_of_nodes + 1,

false

);

66 dp

.assign(number_of_nodes + 1, 0);

69

std::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