Some base Java algorithms