Turn on thread page Beta
    • Thread Starter
    Offline

    0
    ReputationRep:
    not too sure if this is the right place to post this, but can anyone please help me with this question:

    Code:
    Consider the program (valid for inputs n => 1)

    foo(int n) {
    bar();
    if (n==1)
    return;
    foo(n-1);
    foo(n-1);
    foo(n-1);
    }

    Let C(n) be the number of times the function bar() is called when we call
    foo(n). Write down a recurrence relation for C(n).

    also, what is the boundary condition for the recurrence relation when c(1).

    Thanks
 
 
 
Reply
Submit reply
Turn on thread page Beta
Updated: March 5, 2008

University open days

  • University of Bradford
    All faculties Undergraduate
    Wed, 21 Nov '18
  • Buckinghamshire New University
    All Faculties Postgraduate
    Wed, 21 Nov '18
  • Heriot-Watt University
    All Schools Postgraduate
    Wed, 21 Nov '18
Poll
Black Friday: Yay or Nay?

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.