Big O Notion Help for project
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Thread: Big O Notion Help for project

  1. #1
    Join Date
    Oct 2012
    Posts
    5

    Red face Big O Notion Help for project

    hello guys i am in 3th years of studying in uni,i am toke this example as a heading of my project and need answers for it with all thanks, i am software eng

    first part: O(g(n)) for this:


    (n + 3 )(n + n2+ 4)
    5logn+3n+1000
    Logn+ 100 +1/ n2
    100n2+ ½ n3 +5
    (3n2 + 4)3



    second part : number of operation of this


    1)
    if (condition)
    { cout<<”Hello”<<endl; }
    else
    {
    for (i = 0; i < N; i++) {
    cout<<”Hi”<<endl;
    }
    }



    2)for (i = 0; i < N; i++) {
    for (j = i+1; j < N; j++) {
    sequence of statements
    }
    }



    3)for (i = 0; i < 2*N; i++) {
    sequence of statements
    }
    for (j = 0; j < M-1; j++) {
    sequence of statements
    }



    4)
    void fun(int k)
    {
    for (i = 0; i < N; i++) {
    sequence of statements
    }
    }
    void main(){
    //declaration statements
    for (i = 0; i < N; i++) {
    fun(i);
    }
    }

  2. #2
    Join Date
    May 2007
    Posts
    798

    Re: Big O Notion Help for project

    Give us your answers first and then we can help you out.

  3. #3
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: Big O Notion Help for project


  4. #4
    Join Date
    Oct 2012
    Posts
    5

    Re: Big O Notion Help for project

    this my answer for first part:

    first: n3

    sec:n

    third:n2

    forth:n2

    five:n6

  5. #5
    Join Date
    May 2009
    Posts
    2,413

    Re: Big O Notion Help for project

    Quote Originally Posted by javaguys View Post
    this my answer for first part:
    Your notation is somewhat ambiguous since you don't separate multiplication and power-of clearly.

    Still the Ordo complexity of an expression is determined by the fastest growing term when N approaches infinity. In my view you've got it wrong in the third and fourth example. They should be O(logN) and O(N^3) respectively.

  6. #6
    Join Date
    Oct 2012
    Posts
    5

    Re: Big O Notion Help for project

    thanks bro,i want o(n) of it, as i said above for:
    1)
    (n + 3 )(n + n^2+ 4)

    2)5logn+3n+1000


    3)Logn+ 100 +1/ n^2

    4)100n^2+ ½ n^3 +5

    5)(3n^2 + 4)^3

    still wait answers
    Last edited by javaguys; October 4th, 2012 at 08:59 AM.

  7. #7
    Join Date
    May 2009
    Posts
    2,413

    Re: Big O Notion Help for project

    Quote Originally Posted by javaguys View Post
    still wait answers
    I think you got it all right except for 3 and 4 (for which I gave suggestions in my previous reply).
    Last edited by nuzzle; October 4th, 2012 at 09:46 AM.

  8. #8
    Join Date
    Oct 2012
    Posts
    5

    Re: Big O Notion Help for project

    O(logN) and O(N^3) for third and fourth this is true answer?

    hmmm, what about part B bro?

  9. #9
    Join Date
    May 2009
    Posts
    2,413

    Re: Big O Notion Help for project

    Quote Originally Posted by javaguys View Post
    O(logN) and O(N^3) for third and fourth this is true answer?
    Yes, I would say so. The Ordo complexity is determined by the term that grows the fastest asymptotically. And that's the term you picked in all cases except in 3 and 4. In 3 it's log(n) and in 4 it's n^3 so these will determine the complexity.

    But don't take what I say at face value. After having studied software engineering for 3 years at a university you should know this better than I do.

    hmmm, what about part B bro?
    Yes what about it? If you suggest something with a motivation I'll tell you what I think.

  10. #10
    Join Date
    Oct 2012
    Posts
    5

    Re: Big O Notion Help for project

    i know how to find number of operation, but i need to know big o of this codes in part b, i want to tell you that just first material talking about algorithms so sorry if i need just Little help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center