Since you have two nested loops, you have run-time complexity O(m*n)
. This is because, for n
- Person
in deepCopyPersonSet
you repeat m
again. n
in this example, this is the number Person
in personList
.
Your code is basically:
for(int i = 0, i < m, i++)
for(int j = 0, j < n, j++)
For each iteration m, we have n code iterations
source
share