linear test algo complete