SHARE
TWEET

Untitled

a guest Oct 10th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from tp_btree import BTree
  2.  
  3. def btree2list(B):
  4.  
  5.     res=[]
  6.     _btree2list(B,res)
  7.     return res
  8.  
  9. def _btree2list(B,l):
  10.    
  11.     for i in range(len(B.keys)+1) :
  12.         if(i!=0):
  13.             l.append(B.keys[i-1])
  14.         if(B.children != []):
  15.             _btree2list(B.children[i],l)
  16.        
  17.    
  18.  
  19.  
  20. B = BTree([22],[BTree([15],[BTree([8,12],None),BTree([18,19,20],None)]),BTree([27,41],[BTree([24,25],None),BTree([30,35,38],None),BTree([45,48],None)])])  
  21.    
  22. print(btree2list(B))
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