Question d’entretien chez Google

Find the next larger node and write down code

Réponse à la question d'entretien

Utilisateur anonyme

14 janv. 2011

private static BSTNode getTheNextLargerElement(BSTNode node, int x) { if(node == null) return null; BSTNode returned; if(node.info > x) { returned = getTheNextLargerElement(node.left, x); if(returned == null) { return node; } return returned; } return getTheNextLargerElement(node.right,x); }

1