Corrected the bug: the frontier was not explored by one level at a time, but rather at 2^(n-1) level at step n.