Confused about how to exactly determine the complexity of an Algorithm
To prove that an algorithm is in $P$ you basically have two options:


Show how to solve it using a number of operations that is polynomial in the size of the input. This means you have to specify a Turing machine to do it, and prove that each of the operations takes a polynomial amount of time. Alternatively, you would prove that the turing machine spends a polynomial amount of steps in any non-accept/reject state.
Show that your problem can be reformulated as a already-known problem previously proven to be in $P$. Here you have to prove that the reformulation is correct and that it takes polynomial time.