# computational complexity of a tree pruning algorithm

I've just designed an algorithm to prune a tree related to a particular fluid dynamics problem, and I need to determine its computational complexity; however, since I'm just a newcomer (from mechanical engineering) to the computational complexity theory, I'm not sure about the following reasoning:

The while loop iterates once, which means it continues till all elements of $L$ are examined. Moreover, the running time of each line as assumed to be 1.

AFAIK, the outer loop (line 1) counts $n$ assuming that $L$ has $n$ elements. Thus, the computational complexity is proportional to the input size. Moreover, each inner operation of the algorithm counts 1, so the overall computational complexity should be $O(n)$.

Can you please confirm the credibility of the reasoning above?

• We discourage "please check whether my answer is correct" questions, as only "yes/no" answers are possible, which won't help you or future visitors. See here and here. Can you edit your post to ask about a specific conceptual issue you're uncertain about? As a rule of thumb, a good conceptual question should be useful even to someone who isn't looking at the problem you happen to be working on. – D.W. Jan 13 '18 at 20:11
• To help you work out the answer on your own, I suggest you try to work through your reasoning in more detail. Why do you think that each iteration of the outer loop takes $O(1)$ time? How many times might the while loop iterate? What is the running time of each individual line? You might try applying the methods in cs.stackexchange.com/q/23593/755, then edit the question to show us what progress you've made and what step specifically you are uncertain about. – D.W. Jan 13 '18 at 20:13
• @D.W.: Thanks for your comments. First of all, I'm asking about a specific issue which is the computational complexity of the algorithm. Second, I'd declared my progression up to now, which is my current belief that the computational complexity is linear time. Additionally, I considered $O(1)$ for each inner operation since each of those operations can be done in one operation. – A.Loc Jan 13 '18 at 20:22
• @D.W.: The main question is not "yes/no", but "what is the computational complexity of this algorithm". The current "yes/no" format is indeed because of presenting my progression. – A.Loc Jan 13 '18 at 20:24
• @D.W.: The questions you asked about more details are addressed in the updated question. – A.Loc Jan 13 '18 at 20:27