0

I already read Does time complexity changes as we change our programming language?

but my question is if time complexity doesn't change according to language then which is the base language on which we should calculate time complexity. is it C/C++ or any other?

To get element in array in java I use .contains method. so does that mean its O(1) ? if not then how will i know that what logic is running behind .contains or any other function. who will decide time complexity in such cases?

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
user
  • 25
  • 7
  • Does this answer your question? [Does time complexity changes as we change our programming language?](https://stackoverflow.com/questions/53919758/does-time-complexity-changes-as-we-change-our-programming-language) – Nicol Bolas Feb 10 '20 at 16:58
  • As stated in that answer: "*The choice of programming language only matters inasmuch as it affects our perception of what we can ignore; but it does not actually change the time complexity.*" Or more specifically, you don't calculate time complexity based on a language. – Nicol Bolas Feb 10 '20 at 16:58
  • so time complexity depends on C language? – user Feb 10 '20 at 17:00
  • As I said, "*you don't calculate time complexity based on a language*". So the question is moot. – Nicol Bolas Feb 10 '20 at 17:01
  • i understood, but problem is if i write a program in c and same program in java using library functions then how will i determine time complexity of my program? – user Feb 10 '20 at 17:03
  • 1
    Does this answer your question? [How to find time complexity of an algorithm](https://stackoverflow.com/questions/11032015/how-to-find-time-complexity-of-an-algorithm). One of the messages to take from the answers to this other question is that choice of programming language is irrelevant in figuring out the time complexity of an algorithm. – High Performance Mark Feb 10 '20 at 17:09

0 Answers0