$$\begin{array}{ll} \underset{x,y \in \Bbb N_0}{\text{minimize}} & a x^2 + b y^2\\ \text{subject to} & x + y = n\end{array}$$
The function can be rewritten as $g(x) = ax^2+ b(n-x)^2$. Can any one kindly explain how this $g$ is changed to $(a+b)(x-bn/a+b)^2 + c$?

You know that $x+y=n$. It means that you can rewrite $f$ as $$ f\left(x,y\right)=ax^2+b\left(n-x\right)^2 $$ where you know that $n$ is a positive integer. That gives you $$ f\left(x,y\right)=ax^2+bn^2-2bnx+bx^2=\color{red}{\left(a+b\right)}x^2-2bnx+bn^2=\color{red}{\left(a+b\right)}\left(x-\dots\right)^2+\dots $$ To find the $\ \dots \ $ you can think as following :
-> For the moment we know by expending we'll have $\left(a+b\right)x^2$ that we have in the expended form so far so good,
-> However we want a $-2bnx$ so we need a $\frac{bn}{a+b}$ to make the $-2bnx$ appear.
-> But then, it will make a $\left(\frac{bn}{a+b}\right)^2$ appears that we don't want that we'll get rid off by substracting. Hence we have $$ f\left(x,y\right)=\left(a+b\right)\left(x-\frac{bn}{a+b}\right)^2\underbrace{+bn^2-\left(\frac{bn}{a+b}\right)^2}_{=c} $$ You see that if you want this quantity to be minimal (with only $x$ as a variable), you nees to make the $\left(x-\frac{bn}{a+b}\right)^2$ minimal, which is a square, its minimum is $0$, given when $$ x=\frac{bn}{a+b} $$