daily pastebin goal
45%
SHARE
TWEET

Untitled

a guest Sep 19th, 2018 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Node():
  2.     node1 = None
  3.     node2 = None
  4.     deepest_node = None
  5.     def __init__(self,value=None):
  6.             self.value = value
  7.                      
  8.     def add(self,value):        
  9.         if value >= self.value:
  10.                 if self.node2 is None :
  11.                     self.node2 = Node(value)
  12.                     Node.deepest_node = self.node2
  13.                 elif self.node2.value == None:
  14.                     self.node2 = Node(value)
  15.                     Node.deepest_node = self.node2
  16.                 else:
  17.                     self.node2.add(value)                          
  18.         elif self.node1 is None:
  19.              self.node1 = Node(value)
  20.         else:
  21.              self.node1.add(value)
  22.                                
  23.     def delete(self,value):
  24.         if value == self.value:        
  25.             self.value = Node.deepest_node.value if value != Node.deepest_node.value else None
  26.             Node.deepest_node = None          
  27.         elif value >= self.value:
  28.             self.node2.delete(value)
  29.         else:
  30.             self.node1.delete(value)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top