How to handle the repeat until convergence condition in time complexity and summarize the time complexity? I am a novice in complexity calculation. I need to calculate the overall time complexity.
My attempt is given below:
Here, N = number of data points (N&gt;300), C = Number of clusters (2&lt;C&lt;30)

For line 3 to 10, time complexity, TC1 = O(NC)

For line 11 to 12, time complexity, TC2 = O(C)

For line 18 to 22, time complexity, TC3 = O(N*N)

For line 24 to 26, time complexity, TC4 = (how to handle the repeat until convergence- the highlighted section?) (Here, I think TC4 = O(N*N))

For line 16 to 29, the overall time complexity, TC5 = C(TC3+ TC4) = O(N*N*C)// not sure about it due to the lacking confidence in the value of TC4.

For line 31 to 35, time complexity, TC6 = O(N*C*C)

For line 38 to 40, time complexity, TC7 = O(NC)


So, finally, the overall time complexity TC = TC1 + TC2 + TC5 + TC6 + TC7 = O(NC) + O(C) + O(N*N*C) + O(N*C*C) + O(NC) = O(?) //How can I summarize this time complexity using Big-O.

My Questions are:
a) How to handle the highlighted portion when calculating the time complexity?
b) How to summarize the overall time complexity?

Please help.
First of all, repeat until convergence isn't quite a well-defined command. Typically, such instructions are implemented by checking the "progress" of some performance measure, stopping once progress drops below a certain threshold.

In order to estimate the running time ("big O") of such an algorithm, all you need to do is to estimate the number of iterations until convergence. The running time of a simple "repeat until convergence" loop is simply the running time of the loop body times the number of iterations. This is a good upper bound if each loop iteration takes roughly the same time. In more complicated cases, in which the iterations have greatly varying running times, you can use a more accurate measure, namely the total running time of the loop body (across all iterations).

This is the theory. How do you apply it in your particular case? In the loop highlighted in yellow, the loop body has unvarying running time, so you need to figure out how many iterations it takes the loop to converge, and then you multiply that by the time it takes to run a single iteration. Estimating the number of iterations until convergence is beyond the scope of this answer.