Created
November 24, 2018 18:20
-
-
Save Arkango/aa1fbee510a3d1637551e1ed787a7601 to your computer and use it in GitHub Desktop.
levelvisit binarytree
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template < typename F> | |
void visitaPerLivelli(BinaryTree<F>* t){ | |
codePointer<F> C; | |
C.incoda(t->key()); | |
while(!C.codavuota()){ | |
F nodo = C.leggicoda(); | |
C.fuoricoda(); | |
BinaryTree<F>* nodoAlbero = t->lookupNode(nodo); | |
cout << nodoAlbero->key() << "\n"; | |
if(t->lookupNode(nodo)->left != 0){ | |
F val = nodoAlbero->left->key(); | |
C.incoda(val); | |
} | |
if(nodoAlbero->right != 0){ | |
F val1 = nodoAlbero->right->key(); | |
C.incoda(val1); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problema riscontrato con un albero binario di interi