Frage im Vorstellungsgespräch bei Google

Find the next larger node and write down code

Antwort im Vorstellungsgespräch

Anonym

14. Jan. 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