Skip to content

Instantly share code, notes, and snippets.

@Arkango
Created November 24, 2018 18:20
Show Gist options
  • Save Arkango/aa1fbee510a3d1637551e1ed787a7601 to your computer and use it in GitHub Desktop.
Save Arkango/aa1fbee510a3d1637551e1ed787a7601 to your computer and use it in GitHub Desktop.
levelvisit binarytree
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);
}
}
}
@Arkango
Copy link
Author

Arkango commented Nov 24, 2018

Problema riscontrato con un albero binario di interi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment