Time factor determining efficiency of algorithm measured - Data Structure

Q.  When the time factor determining the efficiency of the algorithm is measured?
- Published on 26 Aug 15

a. Counting microseconds
b. Counting the number of key operations
c. Counting the number of statements
d. Counting the kilobytes of algorithm

ANSWER: Counting the number of key operations


  • Nirja Shah   -Posted on 21 Nov 15
    Time complexity mainly depends upon the number of key operations.
    In general, the running time of a loop is the running time of the statements inside the loop.
    for (i=1; i<=n; i++)
         x = x + 5;
    Total Time=O (n)
    For nested loop consider the following example.
    for (i=1; i<=n; i++)
       // inner loop will execute n times
       for (j=1; j<=n; j++)
          k = k+5;
    Total Time=O (n 2 )

Post your comment / Share knowledge

Enter the code shown above:
(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)