use java write algorithms