algorithm utility with C implementation