Ulah considering the code that you give I think this is still O(n^3)
algorithem

i goes from 0 to n -> O(n)
j goes from i to n -> O(n)
and k goes between i and j . This is still O(n) by my opinion.

So finaly we have O(n)*O(n)*O(n) = O(n^3)

I think that this approach always leads to O(n^3) becouse you always
need to consider all the combinations which are
C = N!/(3! * (N-3)!) = N*(N-1)*(N-2)/6 . Which leads to O(N^3)
algorithem.


I think we need some trick from the geometry which I hope someone will
give, becouse I am not able to find so long time already.
Regards and thank you for the replies

Reply via email to