The "Cat behind 7 Doors" Puzzle.
There are 7 doors on a corridor, and a cat is behind one of them. We are trying to find the cat. Interesting thing is that, whenever the door we open is empty, we must close it after, and the cat must move to the door adjacent to him (1 right or 1 left). The cat can move to the door we have just closed.
I was able to find that the solution for the number of trials for $n$ number of doors (when $n$ is larger than 3) is $2(n-2)$. And the order in which we do the trials is starting with 2nd door and going one by one until the $(n-1)$th door, repeating $(n-1)$ and going back to the 2nd door. For example for $5$ doors, the trials are $2$, $3$, $4$, $4$, $3$, $2$.
I understand why this solution is correct. However, I am having a hard time proving if/why this solution is optimal, and I'm not even sure how to make a start on it. Do I use proof by induction? Do I use the formula? Any answers/help will be very much appreciated!



We need to go through everything and see where it leads us, I will try to use as little mathematical notation as I possibly can get away with. Describing these problems with words are more fun in my opinion.
First off we realize that the cat always moves from an odd numbered door to an even numbered door or vice versa.
So let's assume that the cat starts off in an even numbered door, i.e. any of the doors {$2$ or $4$ or $6$}.
So these steps will always work IF the cat started off in an even numbered door. Let's go through everything again and see what happens if it actually started off in an odd numbered door instead, i.e. door {$1$ or $3$ or $5$ or $7$}:
If the cat starts off in an odd numbered door, after we've done the first round, the cat will just be in an even numbered door! This means we can just go back to the first round, and that second time we are guaranteed to find the cat.
So compiling this information for an odd number of doors:
Start with door $2$, increment with $1$ until you reach door $n-1$. If the cat started off in an even numbered door, you will have found it by now; else it started off in an odd numbered door and you just have to repeat the process one more time, which will make you find it.
This will indeed give a worst-case scenario of $\mathcal{O}(n)$, that is if you have to check all doors from $2 \Rightarrow (n-1)$ twice, which is $n-2$ doors twice, which is $2(n-2)$ or $\mathcal{O}(n)$.
Also notice that when we go through the first round, we always pick the door that will minimize the number of doors that the cat can move to; giving the cat as few doors as possible that it can move to. This will yield us the optimal solution.