class Node:
def __init__(self,left=None,right=None,val=0):
self.left=left
self.right=right
self.val=val
#creating a tree
abc=Node(val=1)
abc.left=Node(val=2)
abc.right=Node(val=2)
abc.left.left=Node(val=3)
abc.left.right=Node(val=3)
abc.right.left=Node(val=3)
abc.right.right=Node(val=3)
print(abc.left == abc.right)
Output: False
I Understand they can be stored in different memory locations but "==" operator compares the equality or value of 2 objects. So how are the 2 nodes different?.
This is what ChatGPT told me, is it correct?
the == operator compares the values in the case of lists, but compares the objects themselves in the case of instances of a class like Node.