Summation Algorithm: Understanding n/lgn-i = n/i

In summary, the given equation can be simplified to n times the sum from 1 to log base 2 of n of n over i, where lgn = log base 2 of n. This can be shown by substituting u = lgn - i and summing over the index u. The extra factor of n in the second summation is not necessary.
  • #1
unknown_2
29
0
Hi, I've been looking through my algorithms book/notes and I've come across this summation I'm not quite sure how they got to.

[tex]\sum^{lgn - 1}_{i = 0}\frac{n}{lgn - i}[/tex] = [tex]n\sum^{lgn}_{i = 1}\frac{n}{i}[/tex]

where [tex] lgn = log_{2}n[/tex], it's just to make it simpler


any clue?

cheers,
 
Physics news on Phys.org
  • #2


It looks like you might have an extra factor of [itex]n[/itex] is the second summation. However, consider the sum

[tex]\sum_{i=0}^{\lg{(n)} - 1}\frac{n}{\lg{(n)} - i}[/tex]

Let [itex]u = \lg{(n)} - i[/itex], then [itex]u[/itex] attains values between [itex]1[/itex] and [itex]\lg{(n)}[/itex]. Therefore, summing over this index we find that . . .

[tex]\sum_{i=0}^{\lg{(n)} - 1}\frac{n}{\lg{(n)} - i} = \sum_{u=1}^{\lg{(n)}}\frac{n}{u}[/tex]

As desired.
 
  • #3


yeah I kinda knew the n wasn't supposed to be there, but i put it in just in case i was wrong. your solution makes total sense, thank you very much!
 

FAQ: Summation Algorithm: Understanding n/lgn-i = n/i

What is the sum of n/i for a given range of values?

The sum of n/i can be calculated using the summation algorithm, which involves dividing the range into smaller subranges and then summing up the values for each subrange. For example, if the range is from 1 to n, the algorithm would divide it into subranges of size n/2, n/4, n/8, and so on until reaching a subrange of size 1. The values for each subrange are then summed up, resulting in a total sum of n/i.

How does the summation algorithm work?

The summation algorithm works by breaking down a large range of values into smaller subranges and then summing up the values for each subrange. This is done recursively, with each subrange being divided into smaller subranges until reaching a subrange of size 1. The values for each subrange are then added together to get the total sum.

What is the time complexity of the summation algorithm?

The time complexity of the summation algorithm is O(n), as it involves dividing the range into smaller subranges and then summing up the values for each subrange. This process takes linear time as the range increases, making the overall time complexity of the algorithm linear as well.

Can the summation algorithm be used for any type of range or only for n/i?

The summation algorithm can be used for any type of range, as long as the range can be divided into subranges of equal size. This includes ranges with different types of values, such as integers, decimals, or even strings. As long as the range can be divided and the values can be summed, the algorithm can be applied.

What are the main advantages of using the summation algorithm?

One of the main advantages of using the summation algorithm is its efficiency in calculating the sum of a large range of values. It has a time complexity of O(n), which is much faster than simply adding up all the values in the range. Additionally, the algorithm can be used for any type of range and is easily adaptable to different types of values and ranges.

Back
Top