Both answers are acceptable. Acetic acid can be written as CH3COOH, CH3CO2H, or even C2H4O2. First two formulae are sometimes called semistructural, as they try to show how the molecule really looks like, as opposed to the third one. Potassium acetate can be written as CH3COOK or CH3CO2K, to underline fact that potassium displaces hydrogen from carboxylic group. But sometimes it is written first, as that's the way we write formulae of inorganic salts (starting with the metal).