practical algorithm demo on java