Results 1 to 18 of 18

Thread: Big O Notation question     submit to reddit submit to twitter

  1. #1
    Pens win! Pens Win!!! PENS WIN!!!!!
    Join Date
    Jul 2008
    Posts
    8,637
    BG Level
    8

    Big O Notation question

    I have a problem:

    2^(n+1) +n! +34

    From what I understand, I'm supposed to find the function that dominates the rest, meaning it grows the fastest. Just by looking at the equation, I have to say n! grows the fastest, but I want to know the formal way of solving such a problem. How would one go about finding the answer formally?

    Thanks, Bori

  2. #2
    Sea Torques
    Join Date
    Oct 2007
    Posts
    695
    BG Level
    5

    Factorial or exponential function
    0! = 1
    1! = 1
    2! = 1*2 = 2
    3! = 1*2*3 = 6
    4! = 1*2*3*4 = 24
    5! = 1*2*3*4*5 = 120
    6! = 1*2*3*4*5*6 = 720
    7! = 1*2*3*4*5*6*7 = 5040

    or

    2^(n+1)

    n(0) = 2
    n(1) = 2*2 = 4
    n(2) = 2*2*2 = 8
    n(3) = 2*2*2*2 = 16
    n(4) = 2*2*2*2*2 = 32
    n(5) = 2*2*2*2*2*2 = 64
    n(6) = 2*2*2*2*2*2*2 = 128
    n(7) = 2*2*2*2*2*2*2*2 = 256

  3. #3
    Banned.

    Join Date
    Jul 2005
    Posts
    17,471
    BG Level
    9
    FFXI Server
    Ifrit
    WoW Realm
    Area 52

    Quote Originally Posted by bori View Post
    I have a problem:

    2^(n+1) +n! +34

    From what I understand, I'm supposed to find the function that dominates the rest, meaning it grows the fastest. Just by looking at the equation, I have to say n! grows the fastest, but I want to know the formal way of solving such a problem. How would one go about finding the answer formally?

    Thanks, Bori
    n!!

    [edit]
    wait, no, thats slower


    n!^2

  4. #4
    Pens win! Pens Win!!! PENS WIN!!!!!
    Join Date
    Jul 2008
    Posts
    8,637
    BG Level
    8

    Quote Originally Posted by Kaylia View Post
    n!!

    [edit]
    wait, no, thats slower


    n!^2
    How did you go about getting that?

  5. #5
    Banned.

    Join Date
    Jul 2005
    Posts
    17,471
    BG Level
    9
    FFXI Server
    Ifrit
    WoW Realm
    Area 52

    Quote Originally Posted by bori View Post
    I have a problem:

    2^(n+1) +n! +34

    From what I understand, I'm supposed to find the function that dominates the rest, meaning it grows the fastest. Just by looking at the equation, I have to say n! grows the fastest, but I want to know the formal way of solving such a problem. How would one go about finding the answer formally?

    Thanks, Bori
    First of all, you will never have to make an algorithm that is less efficient. Finding something bigger isn't an issue.


    Secondly, you're right when you target the n!, since it's the term that grow the fast. Finding something that grow faster than an expectional isn't hard. You just need to add something to make it grow even faster (an)! (n!)! (n!)^2 all works


    If dominate mean "is higher at any point", you will to take into account the +34 and 2^(n+1), but it's not hard.


    Looking for formal way? I cant really think of any formal way to do it. If it was in my homeworks, I would simply start and say "n!" is the dominant term, and simply mention it was replaced with a bigger term.

  6. #6
    Sea Torques
    Join Date
    Oct 2007
    Posts
    695
    BG Level
    5

    Quote Originally Posted by willriker View Post
    Factorial or exponential function
    0! = 1
    1! = 1
    2! = 1*2 = 2
    3! = 1*2*3 = 6
    4! = 1*2*3*4 = 24
    5! = 1*2*3*4*5 = 120
    6! = 1*2*3*4*5*6 = 720
    7! = 1*2*3*4*5*6*7 = 5040

    or

    2^(n+1)

    n(0) = 2
    n(1) = 2*2 = 4
    n(2) = 2*2*2 = 8
    n(3) = 2*2*2*2 = 16
    n(4) = 2*2*2*2*2 = 32
    n(5) = 2*2*2*2*2*2 = 64
    n(6) = 2*2*2*2*2*2*2 = 128
    n(7) = 2*2*2*2*2*2*2*2 = 256
    If you really want to get fancy with it, the 34 will dominate the equation until n = 5. then the n! will dominate the equation. At no point will 2^(n+1) dominate the equation.

    You could also just plug this term of the equation into just about any graphing calculator.

  7. #7
    Banned.

    Join Date
    Jul 2005
    Posts
    17,471
    BG Level
    9
    FFXI Server
    Ifrit
    WoW Realm
    Area 52

    Quote Originally Posted by bori View Post
    How did you go about getting that?
    n!! = n * (n-2) * (n -4 )*... is smaller than n! = n * (n-1) * (n-2)...

    It's a stupid notation, but I meant to say something like this (n!)!.

    Because every n are integer, (n!) >= n, meaning (n!)!> n.

  8. #8
    Dr. Salami
    HERO OF TIME

    Join Date
    Oct 2007
    Posts
    7,565
    BG Level
    8
    FFXIV Character
    Selamis Bloodwood
    FFXIV Server
    Coeurl
    FFXI Server
    Unicorn

    False advertising title. Came in thread to expect discussion about orgasms, and big O faces.

  9. #9
    Shimmy shimmy ya shimmy yam shimmy ya
    Sweaty Dick Punching Enthusiast

    Join Date
    Nov 2007
    Posts
    50,913
    BG Level
    10

    Came in this thread expecting a discussion on the anime.

  10. #10
    Old Merits
    Join Date
    May 2006
    Posts
    1,076
    BG Level
    6
    FFXI Server
    Carbuncle
    WoW Realm
    Illidan

    Normally this sort of question is just mental math, you just know which functions grow bigger as they approach infinity. But if you have to prove it, all you'd have to do would be to graph each portion separately and be sure to show all the intersections. In order to do this, break the equation up into the smallest parts you can.

    When working with Big O notation, you get rid of all the constants because they ultimately don't impact the function very much as you go to infinity. For the function 2^(n+1) +n! +34, you only need to graph f(n) = 2^n; g(n) = n!; h(n) = 1. If f(n) grows the largest, the answer is O(c^n); if g(n) grows the largest, the answer is O(n!); if h(n) grows the largest, the answer is O(1). You can see why I say this is mental math, because after you break it down into such simple functions the answer is obvious...

  11. #11
    Sea Torques
    Join Date
    Oct 2007
    Posts
    695
    BG Level
    5

    O(n!)

  12. #12
    Old Merits
    Join Date
    Mar 2005
    Posts
    1,156
    BG Level
    6

    O(exp(n))

  13. #13
    Queen of the Pity Party
    Join Date
    Sep 2007
    Posts
    11,719
    BG Level
    9

    Quote Originally Posted by Hirokei Kiaza View Post
    Came in this thread expecting a discussion on the anime.
    came in this thread expecting a discussion on orgasms myself.

  14. #14
    Banned.

    Join Date
    Aug 2007
    Posts
    2,751
    BG Level
    7
    FFXI Server
    Carbuncle
    WoW Realm
    Trollbane

    http://i45.tinypic.com/dzgh7d.jpg
    wtf do you guys want

  15. #15
    Fake Numbers
    Join Date
    Jul 2008
    Posts
    90
    BG Level
    2

    Obviously, the 34 is not going to be the fastest growing term, so look at 2^(n+1) and n!:

    n! = n(n-1)(n-2)(n-3)...

    If you were to expand the right side, the first term of each factor would multiply together to form an n^n, and the other terms would be on the order of n^(n-1), n^(n-2), etc...

    n! = n^n + O(n^(n-1))

    n^n + O(n^(n-1)) is necessarily larger than 2^(n+1) for all n > 3 just by looking at the first term of the left side alone

    Therefore, the factorial term is the fastest growing term.

  16. #16
    Relic Shield
    Join Date
    Jul 2004
    Posts
    1,574
    BG Level
    6

    another justification:

    e^x = sum n=0 to infinity x^n/n!

    this series converges for all x, and specifically for x = 2

    convergence of series implies the terms go to zero

    hence 2^n/n! -> 0 as n -> infinity

    it's not a proof from first principles since it uses facts (like the series definition of exponential) that are more sophisticated than this problem itself. but it was the first thing that came to my mind

  17. #17
    My Little Ixion
    Join Date
    Aug 2007
    Posts
    8,016
    BG Level
    8
    FFXIV Character
    Olorin Bustyoas
    FFXIV Server
    Sargatanas
    FFXI Server
    Ramuh

    Quote Originally Posted by Colenzo View Post
    oh good lord lol..

  18. #18
    Bagel
    Join Date
    Jan 2006
    Posts
    1,428
    BG Level
    6

    I came in expecting a programming question

Similar Threads

  1. The Big Question :o
    By Ddz in forum General Discussion
    Replies: 3
    Last Post: 2007-02-18, 04:00