Binary Tree/Search Tree

I'm beginning to start data structures and algorithms in Python and I am on Binary trees right now. However I'm really confused on how to implement them. I see some implementations where there are two classes one for Node and one for the tree itself like so:

class Node:
	def __init__(self, data):
	self.right = None
	self.left = None
	self.data = data 

class Tree: 
	def __init__(self):
	self.root = None
	
	def insert()
	def preorder()
	.
	.
	.

However I also see implementations where there is no Node class and instead all the code goes inside the Tree class without the following

def __init__(self):
	self.root = None

Can someone please help me understand why there are two different ways, the pros and cons of each method, the differences between them and which method I should follow to implement a binary tree.

Thank you!

Comments (1)