Question d’entretien chez Meta

How to access data from a tree structure and to sort them into an array?

Réponses aux questions d'entretien

Utilisateur anonyme

19 mai 2012

Is it just a plain rooted tree or is there any property associated with the tree.

Utilisateur anonyme

19 mai 2012

I'm not a CS student, so I'm not sure if it is a plain tree. It is a rooted tree, and each branch with one or two branches below. The solution seems using recursion.

Utilisateur anonyme

26 mai 2012

Generally in this type of question, tree should mean a binary search tree in which each left child (and subtree) is smaller than the parent and right child (and subtree) is greater than the parent. So it requires an inorder traversal of this tree to obtain values in a sorted order that can be put in an array.

Utilisateur anonyme

12 sept. 2016

Small correction to above answer from Vikas... if the tree is a Binary Search tree, than an inorder traversal will by default get the nodes out in sorted order.

Utilisateur anonyme

16 juin 2012

if the tree is a binary tree, an INORDER traversal will provide a sorted series of elements in the binary tree ...