1

I have 2 algorithms

Algorithm 1:

if( Condition1(input)==true )
   print(input);
else
   loop forever;

Algorithm 2:

if( Condition2(input)==true )
   print(input);
else
   loop forever;

for any arbitrary fully-computable condition 1 and 2.

We know both of this algorithm is partial computable.

i want to write a new algorithm (algorithm 3) by this definition.

Algorithm 3:

if (Condition1( input ) ==true) and (Condition2( input ) ==false) 
    print input;

Can i write algorithm3??? and how???

HINT: main problem is: can i write if( Condition2( input ) ==false )???

a d
  • 274
  • Of course you can write it. It is a character string that your word processor should accept. I think the problem is that it is not clear where in the program you would write if( Condition2( input ) ==false ). You can write it anywhere, as it appears to be syntactically correct. It may not do what you want, but you can write it. If you write it after calling Algorithm2, you will never get there. It would be more normal to put this in the else clause of Algorithm2. – Ross Millikan May 14 '13 at 03:54

2 Answers2

1

Replaced: Sure you can do that. You have two conditions. The easiest way is to evaluate them first, evaluate the conjunction, print the input if the conjunction is true, then go on to the two loops you show. You alternate between steps of each algorithm. If they both terminate, you will evaluate the conjunction. Otherwise, you will be looping before the conjunction, but it appears that is what you want anyway.

Added: for the new main problem, sure you can. It will never be satisfied, because if Condition2 is false you loop forever in algorithm2. But you can write it. It is not a syntax error.

Ross Millikan
  • 374,822
0

If I didn't misunderstood you, what you require is not possible. If x is not printed by algorithm 1, then it will loop forever, never getting into condition 2, much less 3. Now, if you want to write algorith 3 by itself, I think the way you did it is correct.