gogoWebsite

Find the Binary Tree Maximum Node

Updated to 2 days ago

As shown in the question: Find the node with the largest value in the binary tree and return

Test data: {1,-5,3,1,2,-4,-5}

Answer: 3

Idea: Find the largest nodes of the left subtree and the right subtree from the root node, and then compare the sizes of the left subtree, right subtree, and root node to get the result. The process of obtaining the largest nodes of the left subtree and the right subtree is similar, so a recursive method can be used.