I am fairly new to generating functions and have been trying to solve the following recurrence for a computer science problem. $$ f(k,d,n) = \sum_{i=1}^{n-1} \binom{n-2}{i-1} \left(\frac{1}{2}\right)^{n-2} \left(\sum_{j=0}^{k} f(k-j,d-1,n-i)\cdot f(j,d-1,i)\right)$$ Note that $$ f:\mathbb{N}^3 \rightarrow [0,1] $$ with the following base cases: $$ \begin{split} f(k,d,1)& = \begin{cases} 1 & (k=0 \wedge d!=0) \vee (k=1 \wedge d=0)\\ 0 & \text{otherwise} \end{cases} \\ f(k,d,2)&= \begin{cases} 1 & ((k=0 \wedge d!=1) \vee (k=2 \wedge d=1))\\ 0 & \text{otherwise} \end{cases} \\ \end{split} $$ and the following domains: $$ \begin{split} n &\in \{1,2,3,4,\ldots\} \\ k &\in \{0,1,2,\ldots,n-1,n\} \\ d &\in \{-\infty,\ldots,-2,-1,0,1,2,\ldots,\infty\} \\ \end{split} $$
From f(k,d,n) and base cases we can derive the following for d<0: $$ f(k,d,n)= \begin{cases} 1 & k=0 \\ 0 & k>0 \end{cases} \\ $$
I would like to mention that $f(k,d,n)$ can also be expressed as the following: $$ f(k,d,n) = \sum_{i=1}^{n-1} \binom{n-2}{i-1} \left(\frac{1}{2}\right )^{n-2} \left(\sum_{j=0}^{k} f(j,d-1,n-i)\cdot f(k-j,d-1,i)\right)$$
Thank you for your time and help in advance.