add time complexity analysis