tanmaytaneja2's blog

By tanmaytaneja2, history, 10 months ago, In English

Very basic doubt but I had to ask :

Say TC == O(n*t); Would their be any significant differences in runtime of (t=10, n=10000), (t=1000, n=100) and (t=10000, n=10)? If yes, why? I tried searching for the answer on the web but I couldn't find a solution which satisfied me.

say code : ~~~~~ int t; cin>>t; while(t--){ int n; cin>>n; for(int i=0; i<4; i++){ for(int j=0; j<n; j++){ // whatever; } } } ~~~~~

(Not talking about the general runtime difference when running the same code multiple times due to processor)

  • Vote: I like it
  • -3
  • Vote: I do not like it

»
10 months ago, # |
  Vote: I like it 0 Vote: I do not like it

In the first case, t*n = 1e6

While in the second and the third cases, t*n = 1e5, which is 10 times faster than the first case

  • »
    »
    10 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    my bad, if t*n is constant, would my runtime differ for different values of t and n?

    • »
      »
      »
      10 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      No, because it runs O(t*n) and t*n is constant.

»
10 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by tanmaytaneja2 (previous revision, new revision, compare).