Beginning algorithm