Given this pseudo code of a function
f(0) = 1;
f(1) = 3;
f(n) = 3 * f(n - 1) - f(n - 2); // for n >= 2.
Is there a non recursive way o
If your question is about whether an equivalent non-recursive definition of the function can be found, you should search for properties of the Fibonacci sequence.
Your sequence can be found by writing the Fibonacci (without the first 2 numbers) and removing every 2nd number: 1, 3, 8, 21, 55, 144, ...
sqrt5 = sqrt(5)
phi = ( 1 + sqrt5 ) / 2
fibonacci(n) = round( power( phi, n ) / sqrt5 )
f(n) = fibonacci( 2*n + 2 )