Pergunta de entrevista da empresa LinkedIn

Traverse a binary there so that the order returned is ordered from smallest to greatest.

Respostas da entrevista

Sigiloso

6 de nov. de 2013

each popping takes logn. hence O(ologn)

5

Sigiloso

25 de fev. de 2013

void inorder (Node * root){ if (root) { inorder(root->left) coutvalue; inorder(root->right) } }

2

Sigiloso

19 de mar. de 2013

This is a binary tree, not a binary search tree. Thus, in order traversal may not work.

Sigiloso

16 de out. de 2013

If it isn't a binary search tree, then just traverse the tree in any which way and put the elements into a min heap. Then iteratively pop the min off the top to return smallest to greatest. Traversal would take O(n), building the min heap is also O(n), and popping min off n times is also O(n) so total is O(n).

1

Sigiloso

21 de set. de 2012

In order binary tree traversal

1