Today at school the teacher asked us to implement a duplicate-deletion algorithm. It\'s not that difficult, and everyone came up with the following solution (pseudocode):
add is O(n), so your CC calculation is wrong. Your algorithm is O(n^2).
add
O(n)
O(n^2)
Moreover, how would remove be implemented? It also looks like it would be O(n) - so the initial algorithm would be O(n^3).
remove
O(n^3)