It depends on how much you trust the company who's doing the trade-in. If it's Google or any other well-established company, I'd just do a simple factory data reset (after first removing your Google account in the
Settings>Accounts menu). Recovering data on a phone that has been factory reset will require some higher level hacking, and it's extremely unlikely that anyone at a company like Google would be interested in doing that (unless you're some kind of international man of mystery with all kinds of secret cabals after your cat photos

).
I'm not sure if the S5 has this option, but another thing you can do is to turn on data encryption for the phone before you reset it. The data encryption would be keyed to your password, so as long as it's a hard password to guess, it'd be pretty difficult to get at the data.