Explore Library
Code QuizAdvanced

Admissible Heuristic Check

Find the reversed condition that misjudges heuristic admissibility.

Codejavascript
// h[i] = heuristic estimate, trueCost[i] = actual cost to goal from node i
function isAdmissible(h, trueCost) {
  for (let i = 0; i < h.length; i++) {
    if (h[i] < trueCost[i]) {
      return false;
    }
  }
  return true;
}

This function is supposed to verify a heuristic is admissible, but the test is wrong. What is the bug?