human
What is a code to largest Independent Set Problem and the other steps required given the following:
Largest Independent Set Problem | DP | A utility function to find max of two integers.
A binary tree node has data , pointer to left child and a pointer to right child.
The function returns size of the largest independent set in a given binary tree.
Calculate size excluding the current node.
Calculate size including the current node.
Return the maximum of two sizes.
A utility function to create a node.
Let us construct the tree given in the above diagram"
How can the above be solved in Python?
assistant
#Here is code to largest Independent Set Problem and the other steps required.
 def max ( x , y ) :
	if ( x > y ) :
		return x
	else :
		return y
class node :
	def __init__ ( self ) :
		self . data = 0
		self . left = self . right = None
def LISS ( root ) :
	if ( root == None ) :
		return 0
	size_excl = LISS ( root . left ) + LISS ( root . right )
	size_incl = 1
	if ( root . left != None ) :
		size_incl += LISS ( root . left . left ) + LISS ( root . left . right )
	if ( root . right != None ) :
		size_incl += LISS ( root . right . left ) + LISS ( root . right . right )
	return max ( size_incl , size_excl )
def newNode ( data ) :
	temp = node ( )
	temp . data = data
	temp . left = temp . right = None
	return temp
root = newNode ( 20 )
root . left = newNode ( 8 )
root . left . left = newNode ( 4 )
root . left . right = newNode ( 12 )
root . left . right . left = newNode ( 10 )
root . left . right . right = newNode ( 14 )
root . right = newNode ( 22 )
root . right . right = newNode ( 25 )
print ( " Size ▁ of ▁ the ▁ Largest " , " ▁ Independent ▁ Set ▁ is ▁ " , LISS ( root ) )