Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from dictionaryAVL import DictAVL
- from dictBinaryTree import DictBinaryTree
- from trees.binaryTree import BinaryTree
- import time
- def concatenaAVL(avl1,avl2):
- #fase di controllo iniziata
- aRoot=avl1.tree.root
- bRoot=avl2.tree.root
- aRootValue=DictBinaryTree.key(aRoot)
- bRootValue=DictBinaryTree.key(bRoot)
- ctrl=controllo(aRootValue,bRootValue)
- if (ctrl==-2):
- return "Errore: due chiavi (quelli nelle radici) sono uguali"
- if ctrl:
- print "Il primo albero è quello con le chiavi strettamente minori del secondo"
- else:
- avl1, avl2 = avl2, avl1 #scambio i due alberi e mantengo quello con le chiavi minori come fosse il primo
- print "Il secondo albero è quello con le chiavi strettamente minori del primo"
- aRoot = avl1.tree.root
- bRoot = avl2.tree.root
- aRootValue = DictBinaryTree.key(aRoot)
- bRootValue = DictBinaryTree.key(bRoot)
- maxAVL1=DictBinaryTree.maxKeySon(aRoot)
- minAVL2=DictBinaryTree.minKeySon(bRoot)
- if not controllo2(DictBinaryTree.key(maxAVL1),DictBinaryTree.key(minAVL2)):
- return "Errore: non tutte le chiavi dell' albero 'minore' sono strettamente minori dell'albero 'maggiore'"
- #fase di controllo finita
- ......
- def controllo1(rootValue1,rootValue2):
- if (rootValue1==rootValue2):
- return -2
- return rootValue1>rootValue2
- def controllo2(max1,min2):
- return max1>min2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement