Need some help on solving this runtime recurrence, using Big-Oh:

```
T(n) = T(n/2) + T(n/2 - 1) + n/2 + 2
```

I don't quite get how to use the Master Theorem here

For n *big enough* you can assume `T(n/2 - 1) == T(n/2)`

, so you can change

```
T(n) = T(n/2) + T(n/2 - 1) + n/2 + 2
```

into

```
T(n) = 2*T(n/2) + n/2 + 2
```

And use Master Theorem (http://en.wikipedia.org/wiki/Master_theorem) for

```
T(n) = a*T(n/b) + f(n)
a = 2
b = 2
f(n) = n/2 + 2
c = 1
k = 0
log(a, b) = 1 = c
```

and so you have (*case 2*, since `log(a, b) = c`

)

```
T(n) = O(n**c * log(n)**(k + 1))
T(n) = O(n * log(n))
```

Similar Questions

I'm trying to solve an arrayoutofbounds exception the exact error is: Exception in thread main java.lang.ArrayIndexOutOfBoundsException: -1 Java Result: 1 public static void emptyBox() { int , b

So if a function or running time is not BigO of f(n), can we say its BigOmega of f(n)?

I need to solve: T(n) = T(n-1) + O(1) when I find the general T(n) = T(n-k) + k O(1) what sum is it? I mean when I reach the base case: n-k=1; k=n-1 Is it sum k, k=1 to n? but the result of this sum

I have implemented in Python an algorithm for solving the game 'Minesweeper'. The program works as follows: Say that the solver clicks a square named 'a'. For sake of example let the number thus revea

Am suppose to return the number of character comparisons. In the while() loop i compare the index of the characters and update the counter. My question is, is it right to do it that way or i have to c

I saw this recursive algorithm to solve the Tower of Hanoi in wikipedia. Could someone explain to me how I get the recurrence equation of this algorithm? Recursive solution label the pegs A, B, C —

I want to load an external website in an iframe. But faced issues due to Same-Origin-Same-domain policy. So for solving this I used the proxy solution in which we send our request to a proxy file (I w

In Cormen's Introduction to Algorithm's book, I'm attempting to work the following problem: Show that the solution to the recurrence relation T(n) = T(n-1) + n is O(n2 ) using substitution (There wasn

I'm working on a calculator in Excel for interstellar travel times. I'm currently solving an equation for Acceleration for Time to arrival like so: =sqrt(distance*2/acceleration) which seems to work

Need help finding a method for solving the following: Given f(n) to be 9f(n/3)+(n2)*(log3n) for all n > 1. And given f(1)=1. Solve for f(n) I tried the master theorem, but all the 3 cases did not f

Im using NSXMLParser to dissect a xml package, I'm receiving &apos inside the package text. I have the following defined for the xmlParser: [xmlParser setShouldResolveExternalEntities: YES]; The

Recursive R(n) if n==1 return 1; else return R(n-1)+n*n*n How do I set up and solve this recurrence relation for this algorithm (sum of n cubes)?

I'm trying to add event in the calendar programatically. I want the event to repeat yearly, every first Monday in February for example. The rule I'm using is this: FREQ=YEARLY;BYDAY=1MO;BYMONTH=2;INTE

I want to solve a recurrence relation with quadratic term in it. For example.. T(n)= T(n-1)^2 + T(n-1) + 2 is a recurrence relation and I have to print its sum mod 100000. How can I do it if without

Anyone know of a (reliable) date recurrence calculator, we're trying to implement something in our app which would allow a schedule to be created, similar to those for recurring meetings in Outlook. W

I have the following problem: f(x) is defined as f1(x) between 0 and 10, f2(x) between 10 and 20 and 0 otherwise. The integral of f(x) between 0 and 20 needs to be greater than or equal to a value K.

I need to interpret a RFC2445 recurrence rule and figure out what dates it occurs on. I don't really want to get into the nitty-gritty of the standard as it seems quite complex, I was wondering if any

Is there a way to solve a general recurrence relation of the form a(n)=a(n-1) * a(n-2).... I mean I can use the matrix method to solve a relation of the form F(n)=a1*F(n-1) + a2*F(n-2).......+ ak*F(n

I have a classic dependency solving problem. I thought I was headed in the right direction, but now I've hit a roadblock and I am not sure how to proceed. Background In the known universe (the cache o

I am trying to find the recurrence relation for this problem on Codechef: http://www.codechef.com/problems/BWALL I know once I find it, I can easily solve it using matrix exponentiation. But I'm havin

I have this recurrence formula: P(n) = ( P(n-1) + 2^(n/2) ) % (X) s.t. P(1) = 2; where n/2 is computer integer division i.e. floor of x/2 Since i am taking mod X, this relation should repeat at leas

I need to develop an application that supports schedules. Example of schedules: Jan 1, 2011 at 9am Jan 1, 2011 from 9am to 10am Every Monday at 9am, from Jan 1, 2011 Every Monday at 9am, from Jan 1

I compared my solution to the one published on haskell.org http://www.haskell.org/haskellwiki/Euler_problems/31_to_40 and don't know what to think of it. Is what I wrote so non-idiomatic, that an aver

Note: this problem has been solved, the actual problem is NOT in this method but the other, so if you're searching for something about Sudoku and finally get into this page, you can absolutely use my

I'm stuck on this recurrence relation pictured in the links below. I have to draw up a recursion tree for the recurrence and eventually solve it but I'd just like some help understanding exactly how t

While solving any programming problem, what is your modus operandi? How do you fix a problem? Do you write everything you can about the observable behaviors of the bug or problem? Take me through the

Hey guys I am trying to implement a method for solving singly even magic square, but it seems to generating the wrong results. Result generated by the following code Enter in size of square: 10 75 75

I a new to dynamic programing and have tried the integer knapsack problem here at SPOJ (http://www.spoj.pl/problems/KNAPSACK/) . However, for the given test cases my solution is not giving the correct

First of all sorry for asking such a basic question. But I am having difficulties understanding substitution method for solving recurrences.I am following Introduction to Algo.s -CLRS. As I am not abl

I tried writing recursion to solve sudoku, and I'm having a problem with the recursion. If it's unsolvable its ok, but if it is solvable it is getting to infinite loop. public static boolean recursion

I have to implement Scheduler like outlook in my .NET application.I have already started working on it but I can't implement Recurrence Pattern.please suggest me that how could i achieve this function

I want to write a code in python to solve a sudoku puzzle. Do you guys have any idea about a good algorithm for this purpose. I read somewhere in net about a algorithm which solves it by filling the w

I'm writing a small web application that keeps track a number of tickets. The users can set recurrence rules to tickets and the tickets will be created automatically based on the recurrence rules. F

I am trying to write code to give numerical answers to a recurrence relation. The relation itself is simple and is defined as follows. The variable x is an integer p(i) = p(i+2)/2 + p(i-1)/2 if i >

There are many many maze solving algorithm out there. But just now I came across a description of a quantum computer that states A quantum computer can try all the paths of a binary maze at one time

Given.. T(0) = 3 for n <= 1 T(n) = 3T(n/3) + n/3 for n > 1 So the answer's suppose to be O(nlogn).. Here's how I did it and it's not giving me the right answer: T(n) = 3T(n/3) + n/3 T(n/3) = 3T

AllDistinct(a1 , . . . , an ) if (n = 1) return True for i := n down to 2 begin if (LinearSearch(a1 , . . . , ai−1 ; ai ) != 0) return False end return True Give a big-O bound on the running time of

Good Morning, I would like to see how Web Developers avoid the double submission issue. So basically my understanding of the problem is as follows: Double submission occurs when an impatient user su

I am doing ray tracing and I have to make intersection between the ray and polynomial so I got the following equation and I have to solve it for t. A(21).(Y.^5) + (A(20).(Y.^4)).X + A(19).(Y.^4) + (A(

Given: F(F(n)) = n F(F(n + 2) + 2) = n F(0) = 1 where n is a non-negative integer. F(129) = ? How can we solve such kind of functional equations programmatically? My programming language of choice is

How can you write the following statement in the given languages? a(0) = 1 a_(n+1) = 1 - 1 / ( a_n + 3) I need to find the smallest value of n when a_n -> 0.732050.... My attempt in Mathematica a[

I am writing a little game which has many circles moving on the screen. I am managing the circles in two threads as following: public void run() { int stepCount = 0; int dx; int dy; while (m_threadTr

I am working on a C# application that relies heavily on recurring events. Following kinds of recurrence are supported: Daily recurrence Weekly recurrence Monthly recurrence Basically, the applicatio

i am studing numerical analysis,and also solving algorithms which is described in book;my problem is about newtons method,in general if some function is given and we have to find root,how can we deter

The recurrence for lcs is: L[i,j] = max(L[i-1,j], L[i,j-1]) if a[i] != a[j] Can you tell me why it is i-1 or j-1? Why isn't L[i,j] = L[i-1,j-1] correct?

I just started playing around with python sympy. For my own reference I'd like to convert functions to latex as they are, i.e. without sympy solving or rearranging them. Example: ex711= (x**2 - 4*x +

I was asked to solve the following recurrence relation in my homework question , T(n) = T(√n) + T(n - √n) + cn This is how I solved the same and also got the right answer. But there is an obvious erro

Does someone know any library or ready source code of parallel implementation of quick iterative methods (bicgstab, CG, etc) for solving Linear System of Equations for example using MPI or OpenMP?

Does Visual Studio 2008 or 2010 have a built-in library which can help in solving all sort of matrix problems? For example: Singular value decomposition Matrix inversion Trace Determinants etc.

I am comfortable with the recurrence relations for the Fibonacci series and for binary search, but I don't know how to find the recurrence relation for this algorithm: Algorithm strange-sort(A[0,,,,,,