Amazon Interview Question

Write an algorithm to find the minimum-depth of a binary tree.

Interview Answer

Anonymous

Jul 27, 2011

int minOfTwo (int nb1, int nb2) { return ((!nb1 && !nb2) ? nb1 : ((nb1 leftSubTree), minDepth(nptr->rightSubTree)); }

1