Re: A Definition of an Algorithm
- From: "Jure" <kupus2_at_hi_tocka_htnet_tocka_hr@xxxxxxxxxxxx>
- Date: Wed, 22 Feb 2006 11:09:55 +0100
I define an algorithm to be a set that has one context and one command.
Command is a function of a context and the result is a set with another
context and another command (these two are new algorithm).
Algorithm_A = (Contex_A, Command_A)
Command_A (Context_A) = (Contex_B, Command_B) = Algorithm_B
Algorithm Algorithm_A = (Contex_A, Command_A) is "empty" if
Command_A (Contex_A) = (Context_A, Command_A)
for every Context_A
Execution of an algorithm:
Exec (Algorithm_A, Context_A) = Exec (Command_A (Context_A)) = Exec
(Algorithm_B, Context_B) = ......
Executing algorithm Algorithm_A in specific context Context_A means
calculating and executing function Command_A (Context_A).
If Algorithm_A is not endless, sooner or later you will get
Exec (Algorithm_A, Context_A) = ...... = Exec (Empty_Algorithm,
Final_Context)
where Empty_Algorithm is "empty" algorithm as defined previously, and we can
say then Final_Contex is the result of executing Algorith_A with initial
data Context_A.
Endless algorithms do not have final result.
Two algorithms A1 and A2 are equal if:
A1 is "empty" and A2 is "empty" (two algorithms that do nothing are the same
algorithm)
Two nonempty algorithms are equal if they are both finite and
Exec (A1, Context_A) = ....... = Exec (Empty_Algorithm, Final_Context_A1)
Exec (A2, Context_A) = ....... = Exec (Empty_Algorithm, Final_Context_A2)
and Final_Context_A1 is equal to Final_Context_A2 for each Context_A that we
start with.
It means that you must have the definition for equal contexts if you want to
derive the definition for equal algorithms.
Example:
Q: Are these two C functions equal?
void Func1 ()
{
a:
goto a;
}
void Func2 ()
{
int i;
a:
i=10;
goto a;
}
A: If your context includes CPU registers then these two functions are not
equal. If you observe them from this context:
int main ()
{
int j;
j=10;
Func1 ();
}
and you context includes variable j, these two functions are equal and you
can put Func2 in place of Func1, result will be the same.
Q: Are these two algorithms "empty"?
A: Depends on the context. If you don't give a *** about some CPU
registers, then there two algorithms are "empty" because they do nothing.
Same rule applies for me also. Some may say that I do nothing but at the
same time I am very busy at cellular lever :))))
Q: Are these two algorithms infinite?
A: Depends on the context. You can execute STOP command to stop CPU or you
can run into infinite loop. Depending on the context that is of your
interest, result may or may not be the same for you
From this example we can see that "empty" algorithm is anything that cannotchange the context. It doesn't matter if you end in infinite loop or you
turn off your computer (but remember to save your data before do any of
these two hahaha).
-----
visit www.vandmia.com and buy only data container that can execute any
operation (fetch, insert, delete at any position) in logarithmic time while
preserving index and key order.
.
- References:
- A Definition of an Algorithm
- From: noson@xxxxxxxxxxxxxxxxxxxxx
- A Definition of an Algorithm
- Prev by Date: Re: High Tech ... Low Life
- Next by Date: Re: High Tech ... Low Life
- Previous by thread: Re: A Definition of an Algorithm
- Next by thread: Robot Videos as Streaming (Including Clango in SARS Wars) !!!
- Index(es):