it depends a lot more on just height.
I am the same as you in height and I ride a 51cm Barron, a small compact Giant and a 16 inch GT Zaskar MTB amongst others which sizes I would have to check.
Did the person who sold you the bike know what they were doing, and importantly have other sizes in stock the could have sold you?