Domanda di colloquio di Tripadvisor

Write code for a binary tree who find the lowest node and bubbles it up to the root.

Risposte di colloquio

Anonimo

24 lug 2014

what do you mean by bubble up!?

3

Anonimo

18 apr 2015

private static Node root; private static Node temp; private static int least = Integer.MAX_VALUE; private static Node swapLeast(Node r) { if (r.val < least) { least = r.val; temp = r; } if (r.left != null) swapLeast(r.left); if (r.right != null) swapLeast(r.right); temp.val = root.val; root.val = least; return root; }