GATE CSE
First time here? Checkout the FAQ!
x
0 votes
25 views
For (i=1;i<n2;i++).                                                    a[i]=i;
asked in Algorithms by (23 points)   | 25 views

O(n2)

loop is simply running from 1 to n2 i.e n2 times..

1 Answer

0 votes

Analysis:

           i=1    2   3   4 .......n

iteration=1   4    9   16.......k2

         sequence is in the form of sum of squares of natural numbers

       so time complexity t(n)=O(n2).

answered by (355 points)  

Related questions

+3 votes
1 answer
1
0 votes
2 answers
2
+2 votes
2 answers
3
asked in Algorithms by Debashish Deka Veteran (51k points)   | 143 views


Top Users Aug 2017
  1. Bikram

    5266 Points

  2. ABKUNDAN

    4730 Points

  3. akash.dinkar12

    3514 Points

  4. manu00x

    3492 Points

  5. rahul sharma 5

    3188 Points

  6. makhdoom ghaya

    2700 Points

  7. just_bhavana

    2432 Points

  8. stblue

    2244 Points

  9. Tesla!

    2090 Points

  10. pawan kumarln

    1876 Points


25,071 questions
32,225 answers
75,102 comments
30,232 users