  We prove a tight bound on the number of realized $0/1$ patterns (or
equivalently on the Vapnik-Chervonenkis codensity) of definable families in
models of the theory of algebraically closed valued fields with a
non-archimedean valuation. Our result improves the best known result in this
direction proved by Aschenbrenner, Dolich, Haskell, Macpherson and Starchenko,
who proved a weaker bound in the restricted case where the characteristics of
the field $K$ and its residue field are both assumed to be $0$. The bound
obtained here is optimal and without any restriction on the characteristics.
  We obtain the aforementioned bound as a consequence of another result on
bounding the Betti numbers of semi-algebraic subsets of certain Berkovich
analytic spaces, mirroring similar results known already in the case of
o-minimal structures and for real closed, as well as, algebraically closed
fields. The latter result is the first result in this direction and is possibly
of independent interest. Its proof relies heavily on recent results of
Hrushovski and Loeser on the topology of semi-algebraic subsets of Berkovich
analytic spaces.
