just an implementation for an algorithms class in java