class Node:
def __init__(self, data):
self.data = data
self.left_child = None
self.right_child = None
class Tree:
def __init__(self):
self.root_node = None
def insert(self, data):
# 1. create the Node object with the data
node = Node(data)
# 2. if root is None, make this new node the root
if self.root_node == None:
self.root_node = node
else:
# 3. ????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????
# 4. start a loop to keep going down until you find place to insert new Node, loop will short circuit when place found
while True:
parent = current
# 5. in loop compare the new node data to current node data and either go left side
# or right side of tree (and if you hit current of None, use the parent pointer to insert new node and
short circuit loop, other wise the loop will continue down the tree
if node.data <= current.data:
current = current.left_child
if current is None:
parent.left_child = node
return
else:
current = current.right_child
if current is None:
parent.right_child = node
return
else:
# 3. if root exists, then create a current pointer initialized to root, and a parent pointer (None initially)
current = self.root_node
parent = None
class Node:
def __init__(self, data):
self.data = data
self.left_child = None
self.right_child = None
class Tree:
def __init__(self):
self.root_node = None
def insert(self, data):
# 1. create the Node object with the data
node = Node(data)
# 2. if root is None, make this new node the root
if self.root_node == None:
self.root_node = node
else:
# 3. ????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????
# 4. start a loop to keep going down until you find place to insert new Node, loop will short circuit when place found
while True:
parent = current
# 5. in loop compare the new node data to current node data and either go left side
# or right side of tree (and if you hit current of None, use the parent pointer to insert new node and
short circuit loop, other wise the loop will continue down the tree
if node.data <= current.data:
current = current.left_child
if current is None:
parent.left_child = node
return
else:
current = current.right_child
if current is None:
parent.right_child = node
return
class Node:
def __init__(self, data):
self.data = data
self.left_child = None
self.right_child = None
class Tree:
def __init__(self):
self.root_node = None
def insert(self, data):
# 1. create the Node object with the data
node = Node(data)
# 2. if root is None, make this new node the root
if self.root_node == None:
self.root_node = node
else:
# 3. ????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????
# 4. start a loop to keep going down until you find place to insert new Node, loop will short circuit when place found
while True:
parent = current
# 5. in loop compare the new node data to current node data and either go left side
# or right side of tree (and if you hit current of None, use the parent pointer to insert new node and
short circuit loop, other wise the loop will continue down the tree
if node.data <= current.data:
current = current.left_child
if current is None:
parent.left_child = node
return
else:
current = current.right_child
if current is None:
parent.right_child = node
return
else:
# 3. if root exists, then create a current pointer initialized to root, and a parent pointer (None initially)
current = self.root_node
parent = None
status | not learned | measured difficulty | 37% [default] | last interval [days] | |||
---|---|---|---|---|---|---|---|
repetition number in this series | 0 | memorised on | scheduled repetition | ||||
scheduled repetition interval | last repetition or drill |