Frage im Vorstellungsgespräch bei Amazon

Print a binary tree level by level

Antwort im Vorstellungsgespräch

Anonym

6. Juni 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(); } }