Convert BST to Greater Tree


  • 0

    Click here to see the full article post


  • 0
    S
    1. can someone please explain how does 2 > 5 > 13 become 20 > 18 > 13
    2. How is this a Greater Tree? what does Greater tree even mean ?
    3. it directly jumps to saying reverse inorder traversal... looking online, reverse inorder traversal is we first traverse all noes (left and right) before traversing its parent... so i am confused :(

  • 0
    S

    here is what others say about reverse in order traversal
    http://algorithms.tutorialhorizon.com/reverse-level-order-traversal/


  • 0

    @seakhar The link you posted is about a reverse level-order traversal.

    1. Each node has the values of all greater nodes added to its value. Said another way, each node has the sum of values in its right subtree added to its value.
    2. I don't think "Greater Tree" is a real thing elsewhere.
    3. A reverse in-order traversal traverses the nodes in descending value. At least, it does in a BST. An in-order traversal is not well-defined for arbitrary trees.

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.