Question d’entretien chez Amazon

Print a binary tree level by level

Réponse à la question d'entretien

Utilisateur anonyme

6 juin 2012

void print_in_order(Node* node) { std::stack nodes; nodes.push(node); while(!nodes.empty()) { Node* temp = nodes.top(); if (temp) { cout value left); nodes.push(node->right); } nodes.pop(); } }