Let $M$ be an $n\times n$ matrix whose characteristic polynomial splits into $n$ linear factors, so that there exists a Jordan canonical form $\mathcal{J}_M$ of $M$. Now suppose $\lambda$ is an eigenvalue of $M$ such that the algebraic multiplicity minus the geometric multiplicity of $\lambda$ is $d>0$, so that there exists a $(d+1)\times (d+1)$ Jordan block $\mathcal{J}_{\lambda}$ of $\mathcal{J}_M$ of the form $$ \mathcal{J}_{\lambda}=\left(\begin{array}{ccccc} \lambda & 1 & 0 & \cdots & 0 \\ 0 & \lambda & 1 & \cdots & 0 \\ \vdots & \vdots & \ddots & \ddots &\vdots \\ 0 & 0 & \cdots & \lambda & 1 \\ 0 & 0 & \cdots & 0 & \lambda \\ \end{array}\right). $$
As such, we know there exists and generalized eigenvector $v$ associated with $\lambda$ (which is not an eigenvector) and an ordered basis $(e_0,e_1,...,e_d)$ of the invariant subspace associated with $\mathcal{J}_{\lambda}$ of the form
$$ (e_d,e_{d-1},e_{d-2},...,e_0)=\left(v,(M-\lambda I_n)v, (M-\lambda I_n)^2v,...,(M-\lambda I_n)^{d}v\right). $$
My question is then the following: Is there an algorithm for determining such a $v$?
Yes,suppose we have $W \subseteq V$ over $\mathbb{C}$ (which is enough to understand the process) and let's suppose that within a block we reduced ourselves without loss of generality in studying the nilpotent part of $f$, which is $h = f -\lambda I_{d}$.
Since take the sequence let's take the sequence $Ker(h) \subsetneq Ker(h^{2}) \subsetneq \cdots \subsetneq Ker(h^{r-1}) \subsetneq Ker(h^{r}) = W$
Let's call $d_{j}$ = $dim Ker(h^{j})$.
Let's focus on $Ker(h^{r-2}) \subsetneq Ker(h^{r-1}) \subsetneq Ker(h^{r}) = W$. Since $Ker(h^{r}) = V$ and $\subsetneq Ker(h^{r-1}) \subsetneq Ker(h^{r})$ we can write $W = Ker(h^{r-1}) \bigoplus U$, where is an arbitrary complementar space of $Ker(h^{r-1})$ in $Ker(h^{r})$,
What's not arbitrary is the dimension of $U$ which is $dim(W)-dim(Ker(h^{r-1})) = d_{r}-d_{r-1} = t,$ for some $t$.
Now you can prove that given a basis of $U$, $\mathcal{B} = \left\lbrace u_{1},\cdots u_{t} \right\rbrace$ that $ \left\lbrace h(u_{1}),\cdots h(u_{t}) \right\rbrace \in Ker(h^{r-1})$(Apply $Ker(h^{r-1})$) and that they are linear independant as well (Once you wrote a linear null combination apply both side $h^{r-2}$ and use the independace of $\mathcal{B}$ to deduce that the coefficients must be $0$).
What we have ? We have that Span$\langle h(\mathcal{B}) \rangle \subseteq Ker(h^{r-1})$ and we also have by construction that $Ker(h^{r-2}) \subsetneq Ker(h^{r-1})$.
The last tricky part is to prove that $Span\langle h(\mathcal{B}) \rangle \cap Ker(h^{r-2}) = \left\lbrace 0 \right\rbrace$ (But the idea of the proof is the same as prooving that $h(\mathcal{B})$ is linearly independant).
Analogously we have that $Ker(h^{r-1}) = Ker(h^{r-2}) \bigoplus U'$, but we a differents, thank to Lemmas proved we can force that a part of the basis of $U'$ be $\langle h(\mathcal{B}) \rangle$, which can be completed to basis in case the already determined dimension of $U'$ is greater that the dimension of $\langle h(\mathcal{B}) \rangle$.
Now just repeat this process in 'blocks of three at times' (The first was $Ker(h^{r-2}),Ker(h^{r-1}),Ker(h^{r})$, now you take $Ker(h^{r-3}),Ker(h^{r-2}),Ker(h^{r-1})$ and so on).
What you will end up with it's a 'ladder' like this
$$\begin{bmatrix}u_{1} \cdots u_{t} & (U) \\ h(u_{1}) \cdots h(u_{t}) & u_{t+1},\cdots u_{t'} & (U') \\ h^{2}(u_{1})\cdots h^{2}(u_{t}) & h(u_{t+1}) \cdots h(u_{t'}) & \cdots & (U'') \\ \vdots & \cdots & \cdots \end{bmatrix}$$
Where the height of the steps it's only determined by $d_{1},cdots,d_{r}$.
Considering the column of this fancy matrix $C_{1},\cdots C_{s}$ (There's no need to call it matrix, it's just easier to visualize the process what we have done), we have that $W$ is the direct sum of the Span of those column where every Span of $C_{i}$ is invariant by construction, and the vectors which contribute to for $C_{i}$ are cyclic basis by construction for $h_{|_{C_{i}}}$, and if you reorder $C_{i}$ from the least to the top you get a Jordan block, but if you recall where we started, $u_{1},\cdots u_{t}$ would be the vectors you needed for (cyclic vectors and each of them will create a Jordan block of size the index of nilpotence of $h$,which in this case is $r$).