Linear subspaces of maximal dimension in a projective quadric. Let $k$ be an algebraically closed field of characteristic $\neq 2$ and $Q_r\subset \mathbb P^n_k$  the quadric hypersurface  given by the equation $x_0^2+\cdots+x_r^2=0 \;(0\leq r\leq n)$ in the projective $n$-space over $k$ with coordinates $x_0, \cdots,x_n$.
Needless to say $Q_r$ is singular if $r\lt n$.   
Question: what is the maximum dimension $M=M(n,r)$ of the linear subspaces $L\subset Q_r$, as a function of $n$ and $r$?
For example $M(3,3)=1$, $M(2,1)=1$ and $M(n,0)=n-1$.
 A: First note, that for a nondegenerate quadratic form on a vector space $V$ the maximal dimension of an isotropic subspace is 
$$
\lfloor \dim(V)/2 \rfloor.
$$
Indeed, if there is a bigger isotropic subspace, it is easy to see that it contains a kernel vector of the form. On the other hand, the existence of such isotropic subspace can be easily shown by induction on $\dim(V)$.
Next, if a quadratic form is degenerate and $K \subset V$ is its kernel space, then a maximal isotropic subspace $I \subset V$ contains $K$ (otherwise $I + K$ is a bigger isotropic subspace).
Finally, isotropic subspaces in $V$ containing $K$ are in bijection with isotropic subspaces in $V/K$ (for the induced quadratic form) via the map, that takes $I \subset V$ to $I/K \subset V/K$.
Combining all this, it is clear that the dimension of a maximal subspace is
$$
\dim K + \lfloor \dim(V/K)/2 \rfloor.
$$
Subtracting 1 to get the dimension of the associated projective space, one obtains
$$
(n-r) + \lfloor (r+1)/2 \rfloor - 1.
$$
