Computer Science, asked by johnykamhua4911, 11 months ago

What should be the time complexity of the isempty(), size(), and tostring() methods?

Answers

Answered by vikrantdeshwal2
0

isEmpty() and size() can be O(n) or O(1), for the reasons stated above. toString's complexity depends on the implementation. Array.toString() is O(n) because you have to traverse the array, whereas, Object.toString() is O(1) because it's simply outputs the object's hashcode.

Similar questions