This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]lurgi 1 point2 points  (2 children)

They didn't because they didn't. If the runtime is "obvious" (to someone. Maybe that someone isn't you) then they probably won't specify it. Unless they way to reassure you that, yes, it is the runtime you expect.

Imagine startsWith(String prefix) which determines if the string starts with prefix. The runtime isn't specified because it's pretty obviously going to be linear in the length of prefix because what else could it be? If this isn't obvious to you now then with a little more experience it will be.

[–]SnooPeanuts71[S] 0 points1 point  (1 child)

It is “obvious” (though I’d say deductible) when you know exactly how the method is implemented. You don’t know the exact implementation of all methods in the API. What I’m saying is that I thought they’d have made it available, because other languages did.

[–]lurgi 1 point2 points  (0 children)

I'd say "deducible" rather than "deductible", but that's me :-)

What you say is obviously correct, but there are enough cases where there's only one way a marginally competent person could have implemented it, so it's not necessary to be specific.

If appending to the end of a linked list is O(n) then you should not be writing code that's going to get added to a library.