Re: O(n) analysis of Bubble and Selection Sort
- From: "BGB / cr88192" <cr88192@xxxxxxxxxxx>
- Date: Thu, 1 Oct 2009 08:01:39 -0700
"Alf P. Steinbach" <alfps@xxxxxxxx> wrote in message
news:ha28u1$42h$1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
* arnuld:
I don't know how you type the letter SIGMA but I think SIGMA(i=0...
(size-1)) = size(size - 1)/2
Yes, if you mean the sum of the numbers 0 through size-1.
But your notation is a bit off.
SIGMA is not an ordinary function. It's the greek uppercase letter
corresponding to Latin "S", short for "Sum". You can regard it as a
function
S(values, f) -> sum
producing the sum f(x1) + f(x2) + f(x3) + ... + f(xn) where xN are the
values in the set 'values'.
But instead of writing e.g.
f(x) = x^2
S( {1...n}, f ) = 1^2 + 2^2 + 3^2 + ... + n^2 = something
we write
n
SIGMA i^2 = 1^2 + 2^2 + 3^2 + ... + n^2 = something
i=1
It's just a more compact way to express the first, avoiding the need to
name the function f (or use lambda notation).
The problem with your expressions is that you have left out the
specification of f.
I personally often use the notation:
sum(n, i=1) i^2
and several of my past scripting languages use a notation sort of like this.
hmm, if added as a C compiler extension:
x = __sum(n; i=1) pow(i, 2);
but, then again, if one were to do this, then it would be almost expected
that one would add in support for integrators, limits, derivatives, ...
but, then again, these are probably better done with library functions (and
function pointers).
similarly, built-in integrators and limits would likely be problematic.
but, then again, if one used a function pointer for these things (noting C's
lack of closures), then one is back to the issue that it would likely be
faster and more convinient just to do it manually via a loop...
.
- References:
- Re: O(n) analysis of Bubble and Selection Sort
- From: arnuld
- Re: O(n) analysis of Bubble and Selection Sort
- From: Alf P. Steinbach
- Re: O(n) analysis of Bubble and Selection Sort
- Prev by Date: Re: O(n) analysis of Bubble and Selection Sort
- Next by Date: Re: Priority Queue confusion
- Previous by thread: Re: O(n) analysis of Bubble and Selection Sort
- Next by thread: Re: O(n) analysis of Bubble and Selection Sort
- Index(es):
Relevant Pages
|