time complexity calculation