0

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:

enter image description here

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?

A.Loc
  • 103
  • 5

0 Answers0