Relation between time complexity and programming language. means below piece of code take o(N) in c , is that code take same time complexity in java?
for (int i = 0; i < N; i ) {
sequence of statements
}
CodePudding user response:
Time complexity is just how long an algorithm will take to run as a function of the size of the input.
So for this specific example (and most cases tbh) yes, it’ll run in the same time complexity regardless of programming language.
The only exception I can think of are built in functions, for which every language may have their own time complexity
CodePudding user response:
It depends on which time we are talking about: if it is the algorithm, both C and Java executed the data entry at the same time. However, it is worth remembering Java runs in a virtual machine, and C runs directly on the computer. Therefore, C will run the program faster.