Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Algorithms
  4. Guides on solving this recurrence relation equation?

Guides on solving this recurrence relation equation?

Scheduled Pinned Locked Moved Algorithms
algorithmshelpquestion
5 Posts 5 Posters 97 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    oslon
    wrote on last edited by
    #1

    T(n)=c if n=1 =2T(n-1)+d if n>1 Find the value of T(n) and thus the time complexity. My attempt at it got stuck. T(n)=4T(n-2)+3d T(n)=8T(n-3)+7d .. .. .. T(n)=8T(n-k)+7d It can't be solved further.

    A J J M 4 Replies Last reply
    0
    • O oslon

      T(n)=c if n=1 =2T(n-1)+d if n>1 Find the value of T(n) and thus the time complexity. My attempt at it got stuck. T(n)=4T(n-2)+3d T(n)=8T(n-3)+7d .. .. .. T(n)=8T(n-k)+7d It can't be solved further.

      A Offline
      A Offline
      Andre Oosthuizen
      wrote on last edited by
      #2

      Quote:

      It can't be solved further

      This does not help us in any way or format, why can it not be solved further, did it freeze, were there an error etc. etc.

      1 Reply Last reply
      0
      • O oslon

        T(n)=c if n=1 =2T(n-1)+d if n>1 Find the value of T(n) and thus the time complexity. My attempt at it got stuck. T(n)=4T(n-2)+3d T(n)=8T(n-3)+7d .. .. .. T(n)=8T(n-k)+7d It can't be solved further.

        J Online
        J Online
        jeron1
        wrote on last edited by
        #3

        Start writing things out more fully then look for the pattern in terms of n .

        T(1) = c

        T(2) = 2T(1) + d
        T(2) = 2c + d -------- take this
        |
        T(3) = 2T(2) + d |
        |
        ____________| and put it here
        |
        /------\
        T(3) = 2(2c + d) + d
        T(3) = 4c + 2d + d
        T(3) = 4c + 3d

        T(4) = 2T(3) + d
        T(4) = 2(4c + 3d) + d
        T(4) = 8c + 6d + d
        T(4) = 8c + 7d

        T(5) = 2T(4) + d
        T(5) = 2(8c + 7d) + d
        T(5) = 16c + 14d + d
        T(5) = 16c + 15d

        "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

        1 Reply Last reply
        0
        • O oslon

          T(n)=c if n=1 =2T(n-1)+d if n>1 Find the value of T(n) and thus the time complexity. My attempt at it got stuck. T(n)=4T(n-2)+3d T(n)=8T(n-3)+7d .. .. .. T(n)=8T(n-k)+7d It can't be solved further.

          J Offline
          J Offline
          jschell
          wrote on last edited by
          #4

          Googling suggests that time complexity requires 'code'. So as a starting point doesn't one need to write the recursive function first?

          1 Reply Last reply
          0
          • O oslon

            T(n)=c if n=1 =2T(n-1)+d if n>1 Find the value of T(n) and thus the time complexity. My attempt at it got stuck. T(n)=4T(n-2)+3d T(n)=8T(n-3)+7d .. .. .. T(n)=8T(n-k)+7d It can't be solved further.

            M Offline
            M Offline
            Marc Antoine Froger
            wrote on last edited by
            #5

            Maybe I didn't understand completely your question, but to me, your function T can be written like this : For any Positive non null integer n => T(n) = ( c + d ) * ( 2^( n - 1 ) ) - d It works also with n = 1 since T(1) becomes ( c + d ) * (2^0) - d => c + d - d => c

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups