Tournament Tree

Definition

= Binary Heap (root is minimum among (root.left and root.right)).

Target : find second minimum.

if root is first min, left > root, right > root. compare root.left and root.right,

  • case 1 : root.left > root.right,

    • root.left can't be second min, search in root.right, candidate = root.right.val;
  • case 2: root.right > root.left,

    • search in root.left. sec min candidate = root.left.val;

results matching ""

    No results matching ""