Computer Science, asked by talemacut2001, 1 year ago

Write an algorithm that accepts a Binary Tree as input and prints its height to standard
output

Answers

Answered by AngshumanRoy
7
logarithm ok friend hope it helps you a lot.
thank you
Answered by phillipinestest
0

"The algorithm that accepts a Binary tree as input and prints its height to standard output is as follows:

Algorithm:

maxheight(bintree)

1. If bintree is is empty

  - return 0

  - exit

2. Else

  - Calculate the maximum height of the left sub tree via the use of recursion

  - Calculate the maximum height of right sub tree via the use of recursion

  - If maximum height of left sub tree is greater than max height of right sub tree

    * increase it by 1

    * return maxleft

  -Else

   * increase the height of right subtree by 1

   * return maxright

3. Stop"

Similar questions