Improves efficiency by pre-initializing the frontier