Let $X_1,...X_n$ random sample from $f(x;\theta)=I_{[\theta-\frac{1}{2};\theta+\frac{1}{2}]}(x)$.
a) Show that $[X_{(1)},X_{(n)}]$ is a confidence interval for $\theta$.
b) Compute the expected length $E(X_{(n)}-X_{(1)})$
c) Find the confidence level.
a) I don't know how to show that $[X_{(1)},X_{(n)}]$ is confidence interval, I think I should find a pivotal quantity with $X_{(1)}$ and $X_{(n)} $ and show that its distibution doesn't depend on $\theta$. Is it right?
b) I found the density function of $X_{(n)}-X_{(1)}$ (Calculations are too large to write here) and get that $E(X_{(n)}-X_{(1)})= \frac{n-1}{n+1}$
c)$P(X_{(1)}\leq \theta \leq X_{(n)})=P(X_{(n)}\geq\theta)-P(X_{(1)}\geq \theta)=(1-F_{X_{(n)}}(\theta))-(1-F_{X_{(1)}}(\theta))$ and just have to compute this probabilities.
In b) and c) I'm almost sure that it's correct, but I just don't not how to do a)
Joint density of $X_1,\ldots,X_n$ is $$f_{\theta}(x_1,\ldots,x_n)=\mathbf1_{\theta-\frac{1}{2}<x_{(1)},x_{(n)}<\theta+\frac{1}{2}}=\mathbf1_{x_{(n)}-\frac{1}{2}<\theta<x_{(1)}+\frac{1}{2}}$$
Clearly $(X_{(1)},X_{(n)})$ is a sufficient statistic for $\theta$, so it is expected that a reasonable confidence interval for $\theta$ would involve the quantities $X_{(1)}$ and $X_{(n)}$ to capture the information about $\theta$.
Since $X_i-\theta+\frac{1}{2}$ are i.i.d $U(0,1)$, we have $X_{(1)}-\theta+\frac{1}{2}\sim \mathsf{Beta}(1,n)$ and $X_{(n)}-\theta+\frac{1}{2}\sim\mathsf{Beta}(n,1)$. Taking expectation gives $E\left[X_{(n)}-X_{(1)}\right]$ directly.
For the confidence interval, you can start from $$P_{\theta}\left[X_{(1)}-\theta+\frac{1}{2}\le c\right]=1-(1-c)^n\quad,\,\forall\,\theta\in\mathbb R$$
Choose $(1-c)^n=\alpha_1$, so that the above becomes
$$P_{\theta}\left[\theta\ge X_{(1)}-\frac{1}{2}+\alpha_1^{1/n}\right]=1-\alpha_1\quad,\,\forall\,\theta\tag{1}$$
In exactly the same way one can show that
$$P_{\theta}\left[\theta\le X_{(n)}+\frac{1}{2}-\alpha_2^{1/n}\right]=1-\alpha_2\quad,\,\forall\,\theta\tag{2}$$
Combining $(1)$ and $(2)$ we have the general result
$$\color{blue}{P_{\theta}\left\{\theta\in \left[X_{(1)}-\frac{1}{2}+\alpha_1^{1/n}, X_{(n)}+\frac{1}{2}-\alpha_2^{1/n}\right]\right\}= 1-\alpha_1-\alpha_2\quad,\,\forall\,\theta}$$
Your question asks for the specific choice $\alpha_1=\alpha_2=\frac{1}{2^n}$.