Analyzing Recurrence Relations: Help with Summations Code

  • Thread starter Thread starter EvLer
  • Start date Start date
  • Tags Tags
    Code
Click For Summary

Homework Help Overview

The discussion revolves around analyzing a recurrence relation represented through nested summations and code. The original poster is attempting to express a recurrence in terms of \( n \) based on a given code structure that involves three nested loops.

Discussion Character

  • Exploratory, Mathematical reasoning, Assumption checking

Approaches and Questions Raised

  • The original poster presents a summation representation of the recurrence but expresses uncertainty about transitioning to \( n \). They question whether to treat \( j = i + 1 \) as a constant. Other participants suggest adjustments to the summation and clarify terms, prompting further inquiries about the derivation of specific expressions.

Discussion Status

Participants are actively engaging with the problem, offering clarifications and corrections. There is an ongoing exploration of the summation terms and their implications, with no clear consensus yet on the best approach to take.

Contextual Notes

There is a mention of a potential typo in the expressions provided, which may affect the understanding of the summation terms. The original poster is also navigating the complexity of breaking down the summation into components dependent on \( n \) and \( i \).

EvLer
Messages
454
Reaction score
0
Hi everyone,
I have the following recurrence to represent in terms of n:
Code:
  n-1    n      j
Sigma Sigma Sigma(c1) =...
 i =1  j = i+1 k=1
Basically, it is an analysis of following code:
Code:
for(i = 1 to n -1)
   for(j = i+1 to n)
       for(k = 1 to j)
      something of O(1)
So, I came up with summations but not sure how to switch to n.
So far I have following:
Code:
 n-1    n                    n-1    n            n-1      n       
Sigma Sigma (c1)(j-1) = c1 Sigma Sigma   j  - c1 Sigma Sigma 1;  
 i=1  j=i+1                 i=1   j=i+1          i=1   j=i+1
Second part resulted in c1[n(n-1) - [n(n+1)]/2 - (n-1)]; but I am stuck on the first part. Should I regard j = i + 1 as some constant?

Thanks a lot.
 
Last edited:
Physics news on Phys.org
You shouldn't have "j - 1" you should just have j, i.e.

\sum _{i = 1} ^{n - 1}\sum _{j = i + 1} ^n \sum _{k = 1} ^j c_1 = \sum _{i = 1} ^{n - 1}\sum _{j = i + 1} ^n jc_1

Now:

\sum _{i = 1} ^{n - 1}\sum _{j = i + 1} ^n jc_1 = \sum _{i = 1} ^{n - 1}\left (\sum _{j = 1} ^n jc_1 - \sum _{j = 1} ^i jc_1\right ) = c_1 \sum_{i = 1} ^{n - 1}\left (\frac{n(n + 1)}{2} - \frac{i(i - 1)}{2}\right )

See if you can go from there.
 
Thanks a lot for the reply.
I have some questions on your solution though:
how did you come up with i(i-1)/2 for the second expression in the parenthesis but n(n+1)/2 for the first? I know there is a minus before the i-expression but is it affecting the inner i-parenthesis?
From where you left off, I am thinking of breaking off the summation into two: one dependent on n and other dependent on i, is this the right direction?

Again, thank you very much.
 
Sorry, that was just a typo. It should be n(n+1)/2, and i(i+1)/2. As for the rest, I'm sure you can figure out the right direction without me telling you.
 

Similar threads

  • · Replies 16 ·
Replies
16
Views
1K
  • · Replies 0 ·
Replies
0
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 7 ·
Replies
7
Views
5K
Replies
8
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 6 ·
Replies
6
Views
3K
Replies
5
Views
4K