def tree(dept,indx,val,height,who):
if height==dept:
return val[indx]
if who:
return max(
tree(dept+1,indx*2,val,height,False),
tree(dept+1,indx*2+1,val,height,False)
)
else:
return min(
tree(dept+1,indx*2,val,height,True),
tree(dept+1,indx*2+1,val,height,True)
)
val=[1,2,3,4,5,6,7,8]
print("minmax : ",tree(0,0,val,3,True))
0 Comments