Advertisement
Guest User

Untitled

a guest
Dec 13th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.46 KB | None | 0 0
  1. from dictionaryAVL import DictAVL
  2. from dictBinaryTree import DictBinaryTree
  3. from trees.binaryTree import BinaryTree
  4. import time
  5.  
  6. def concatenaAVL(avl1,avl2):
  7.  
  8.     #fase di controllo iniziata
  9.  
  10.     aRoot=avl1.tree.root
  11.     bRoot=avl2.tree.root
  12.     aRootValue=DictBinaryTree.key(aRoot)
  13.     bRootValue=DictBinaryTree.key(bRoot)
  14.     ctrl=controllo(aRootValue,bRootValue)
  15.     if (ctrl==-2):
  16.         return "Errore: due chiavi (quelli nelle radici) sono uguali"
  17.     if ctrl:
  18.         print "Il primo albero รจ quello con le chiavi strettamente minori del secondo"
  19.     else:
  20.         avl1, avl2 = avl2, avl1         #scambio i due alberi e mantengo quello con le chiavi minori come fosse il primo
  21.         print "Il secondo albero รจ quello con le chiavi strettamente minori del primo"
  22.         aRoot = avl1.tree.root
  23.         bRoot = avl2.tree.root
  24.         aRootValue = DictBinaryTree.key(aRoot)
  25.         bRootValue = DictBinaryTree.key(bRoot)
  26.     maxAVL1=DictBinaryTree.maxKeySon(aRoot)
  27.     minAVL2=DictBinaryTree.minKeySon(bRoot)
  28.     if not controllo2(DictBinaryTree.key(maxAVL1),DictBinaryTree.key(minAVL2)):
  29.         return "Errore: non tutte le chiavi dell' albero 'minore' sono strettamente minori dell'albero 'maggiore'"
  30.  
  31.     #fase di controllo finita
  32.  
  33. ........ #devo finire il resto...
  34.  
  35.  
  36. def controllo1(rootValue1,rootValue2):
  37.     if (rootValue1==rootValue2):
  38.         return -2
  39.     return rootValue1>rootValue2
  40.  
  41. def controllo2(max1,min2):
  42.     return max1>min2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement