Children Sum Property

def changeTree(root): 
if root ==None:
return
left=0
right=0
if root.left!=None:
if root.left.data<root.data:
root.left.data=root.data
changeTree(root.left)
left=root.left.data
if root.right!=None:
if root.right.data<root.data:
root.right.data=root.data
changeTree(root.right)
right=root.right.data
if not (root.left==None and root.right==None):
root.data=left+right

--

--

--

Tech-Enthusiast, Coder,Explorer,Geeky,Software Engineer |A piece of code delivers everything that you need. The world is all about codes.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Enemy Movement Types

Introduction to Next.js

FCC Speedrun: Random Quote Machine

How to Integrate Slack into a Node app

Understanding The React Source Code IX

The 5 Most Popular Programming Languages

Creating Push notification job with SNS, Lambda and Node.js

Beginning of Something great

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Dhanarajappu

Dhanarajappu

Tech-Enthusiast, Coder,Explorer,Geeky,Software Engineer |A piece of code delivers everything that you need. The world is all about codes.

More from Medium

How to make a DynamoDB table by granting an EC2 Instance least privileges

Examples of a finite automaton

104. Maximum Depth of Binary Tree

First Collaborative project at — Masai School