Describe a PDA that accepts all strings over $\{a, b\}$ that have as many $a$’s as $b$’s. I'm having my exam in few days and I would like help with this 

Describe a PDA that accepts all strings over $\{ a, b \}$ that have as many $a$’s as $b$’s.


Hint:
Any word $w$ with same number of $\mathtt{a}$s and $\mathtt{b}$s can be split into words $w = w_1w_2w_3\ldots w_n$ such that no proper subword of $w_i$ has same number of $\mathtt{a}$s and $\mathtt{b}$s (if you were to graph the word, where $\mathtt{a}$ is $+1$ and $\mathtt{b}$ is $-1$, then the splitting points are exactly those where your graph hits zero). For any such a subword $w_i$ the letters $\mathtt{a}$ and $\mathtt{b}$ behave exactly like parentheses:


*

*$\mathtt{a}=\mathtt{(}$ and $\mathtt{b}=\mathtt{)}$ when there is always more $\mathtt{a}$ than $\mathtt{b}$,

*$\mathtt{a}=\mathtt{)}$ and $\mathtt{b}=\mathtt{(}$ when there is always more $\mathtt{b}$ than $\mathtt{a}$. 


Good luck!
