# #tree characteristic --> every node only has one one parent
# #if not satisfy --> not a tree
# #not linked list (linear -- but structure non linear) as
# well. this qn is a hybrid qn
# #this is a free spaced ll --> the left connects all the
# #free spaces --> the last node of free spaced ll has left 0
# # null value = 0.
# #dont do +1 since there is a free spaced ll
class ConnectionNode:
def __init__(self, DataValue = None):
self.DataValue = DataValue
self.LeftChild = -1
self.RightChild = -1
class LinkedList:##not compulsory to have LL class --> can be
# #procedural
def __init__(self):
self.Root = 1 ##although shld be 0, qn ask for 1. put 1
self.NextFreeChild = 1
self.RobotData = [ConnectionNode() for i in range(25)] ## need to times 26 since range(25) will only give 24. we want 25
LL = LinkedList()
Click Run or press shift + ENTER to run code