some classic DM algorithm writen in java