Results 1 to 10 of 10

Thread: CS Algorithm question     submit to reddit submit to twitter

  1. #1
    Nidhogg
    Join Date
    Oct 2006
    Posts
    3,665
    BG Level
    7

    CS Algorithm question

    well let's say i have f(n) = n(2^n) and g(n) = 3^n,
    3^n obviously grows faster, but how should i prove this? let's say i wanna prove f(n) = O(g(n))
    any hint?

  2. #2
    Relic Shield
    Join Date
    Mar 2007
    Posts
    1,658
    BG Level
    6
    FFXI Server
    Bahamut
    WoW Realm
    Cho'gall

    Re: CS Algorithm question

    9

  3. #3
    Chram
    Join Date
    Jun 2006
    Posts
    2,539
    BG Level
    7

    Re: CS Algorithm question


  4. #4
    Salvage Bans
    Join Date
    Jan 2007
    Posts
    765
    BG Level
    5
    FFXI Server
    Ragnarok

    Re: CS Algorithm question

    Master's Theorem. If that doesn't work, MAKE it work.

  5. #5
    Final Fantasy XI Music Devotee

    Join Date
    Dec 2005
    Posts
    723
    BG Level
    5
    FFXIV Character
    Vianne Nys
    FFXIV Server
    Excalibur
    FFXI Server
    Quetzalcoatl

  6. #6
    Black Belt
    Join Date
    Jul 2004
    Posts
    5,720
    BG Level
    8
    FFXI Server
    Bahamut

    Re: CS Algorithm question

    Quote Originally Posted by The_OG_Nelta
    well let's say i have f(n) = n(2^n) and g(n) = 3^n,
    3^n obviously grows faster, but how should i prove this? let's say i wanna prove f(n) = O(g(n))
    any hint?


    D1(n) = T(n)-T(n-1) = a*n2+b*n+c-a*(n-1)2-b*(n-1)-c = 2a*n-a+b

    DUH!

  7. #7
    Cat
    Guest

    Re: CS Algorithm question

    Take the largest growth item from both sides, since it will be the only significant growth factor as n goes to inifinty.
    Thus f(n) = 2? and g(n) = 3?.
    Thus f(n) = O(g(n)).

  8. #8
    i'm awesome.
    Join Date
    May 2005
    Posts
    9,218
    BG Level
    8

    Re: CS Algorithm question

    Knowing certain things work that way and proving it are two different things.

    If you all tried to pull that shit on a Calculus test you'd get points taken off, unless your teacher was an idiot.

    My calculus is rusty but try the root test with 2^n and 3^n. Should be easy enough...

    Edit: If you haven't had Calc2 yet that would explain why you're finding this difficult, in which case I feel bad because that would really suck

  9. #9
    Relic Horn
    Join Date
    Mar 2006
    Posts
    3,215
    BG Level
    7

    Re: CS Algorithm question

    Take the ratio of g(n) to f(n) as n approaches infinity.

    In this case that would be (3^n)/(n(2^n)) = ((3/2)^n)/n.
    Now if the limit of ((3/2)^n)/n as n approaches infinity is greater than 1, then g(n) grows faster, if it's less than 1, then f(n) grows faster, and if it's 1 then they grow at the same rate. I don't remember how to resolve that limit, but you're the one taking the class so you should be able to figure it out better than me.

  10. #10
    Relic Shield
    Join Date
    Mar 2007
    Posts
    1,658
    BG Level
    6
    FFXI Server
    Bahamut
    WoW Realm
    Cho'gall

    Re: CS Algorithm question

    Fucking alphabet math.

Similar Threads

  1. A question to Yummy and Clistophy!!
    By Hirronimus in forum General Discussion
    Replies: 2
    Last Post: 2004-08-11, 00:14
  2. Just got a question for you guys
    By Blackwar in forum General Discussion
    Replies: 3
    Last Post: 2004-08-06, 20:14