Re: [algogeeks] Re: Adobe Question : Convert a number given in base B1 to a number in base B2 without using any intermediate base

2010-08-29 Thread rahul patil
check this code . if it works correctly ? reverse the ans and you will find the no converted in target base.(ignore extra 0's) #include #include #include #define MAX 10 int main() { int i; int b1,b2; char no1[MAX] = "",no2[MAX] = ""; int *result = (int *) calloc (sizeof(int),20); in

Re: [algogeeks] how to check a problem p or np complete or incomplete

2010-08-29 Thread Yan Wang
You can try to reduce a classic NPC problem to the target problem. If this can be done, you can surely say the target problem is a NPC problem. On 8/29/10, mohit verma wrote: > hi all, > can anyone tell me how can one recognize a given problem whether it is NP > complete or incomplete or N comp

Re: [algogeeks] Re: Will miracle ever print ?

2010-08-29 Thread VINAY KUMAR NAIDU
I think by defining equivalnces also we can print miracle for ex -1%2 and 1%2 are same and 1%2!=0 odd%2 and -odd%2 are same and odd!=0 but -1%2 is giving -1 . but don't know how to make it 1. help someone if possible. On Mon, Aug 30, 2010 at 12:40 AM, srinivas reddy wrote: > @aravind thanks y

Re: [algogeeks] Re: Will miracle ever print ?

2010-08-29 Thread srinivas reddy
@aravind thanks yarr E.srinivas m.c.a nit durgapur On Mon, Aug 30, 2010 at 12:34 AM, Aravind wrote: > @srinivas ok it prints miracle.. this is hw the code will look after > macro substitution... > if (1 || 1 == -1 || 1 && 1 || 1 != 0) > > On Mon, Aug 30, 2010 at 12:18 AM, srinivas reddy > w

Re: [algogeeks] Re: Will miracle ever print ?

2010-08-29 Thread Aravind
@srinivas ok it prints miracle.. this is hw the code will look after macro substitution... if (1 || 1 == -1 || 1 && 1 || 1 != 0) On Mon, Aug 30, 2010 at 12:18 AM, srinivas reddy wrote: > @aravind no aravind it's working plz run my code and check it > > > On Mon, Aug 30, 2010 at 12:12 AM, Ara

[algogeeks] @aravind

2010-08-29 Thread srinivas reddy
plz first of all run my code it's working -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com.

Re: [algogeeks] Re: Will miracle ever print ?

2010-08-29 Thread srinivas reddy
@aravind no aravind it's working plz run my code and check it On Mon, Aug 30, 2010 at 12:12 AM, Aravind wrote: > @srinivas i think miracle will not be printedas n||n is n , so m==p is > n == -n and this is not possible. > > > On Mon, Aug 30, 2010 at 12:00 AM, srinivas reddy > wrote: > >>

[algogeeks] Re: Help with Increment Operators in C!

2010-08-29 Thread jagadish
@Dave: Thanks alot for enlightening us! @Manju: ya.. you are right. The same was stated by me in the my prev reply! :-) On Aug 29, 10:50 pm, Manjunath Manohar wrote: > it is compiler dependant da..the evaluation of this kind of expressions -- You received this message because you are subscribe

Re: [algogeeks] Re: Will miracle ever print ?

2010-08-29 Thread Aravind
@srinivas i think miracle will not be printedas n||n is n , so m==p is n == -n and this is not possible. On Mon, Aug 30, 2010 at 12:00 AM, srinivas reddy wrote: > @ aravind i wrote the code without macro isn't right plz check it.. > > > On Sun, Aug 29, 2010 at 11:56 PM, Aravind wrote: > >

Re: [algogeeks] Re: Binary tree to LL

2010-08-29 Thread albert theboss
@Chonku: you cant use "next" pointer in that... you have to make link list such that right ptr points to next node and left pointer to prev node Am i right??? correct me if i am wrong. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" grou

Re: [algogeeks] Re: Will miracle ever print ?

2010-08-29 Thread srinivas reddy
@ aravind i wrote the code without macro isn't right plz check it.. On Sun, Aug 29, 2010 at 11:56 PM, Aravind wrote: > @srinivas the macro will replace the 'data' with 1 || 1 and this will make > the if condition true and print miracle. > > > On Sun, Aug 29, 2010 at 11:24 PM, srinivas reddy > wr

Re: [algogeeks] Re: Will miracle ever print ?

2010-08-29 Thread Aravind
@srinivas the macro will replace the 'data' with 1 || 1 and this will make the if condition true and print miracle. On Sun, Aug 29, 2010 at 11:24 PM, srinivas reddy wrote: > @aravind this is slight modification to your one and this is generalized > one if it is not the way plz inform me > > #incl

Re: [algogeeks] Re: Will miracle ever print ?

2010-08-29 Thread srinivas reddy
@aravind this is slight modification to your one and this is generalized one if it is not the way plz inform me #include void main() { int m,n,p; printf("enter data"); scanf("%d",&n); m=n||n; p=-n||-n; if(m==p && n!=0) printf("miracle"); } here i replace data with m and -data with n so the code i

Re: [algogeeks] Help with Increment Operators in C!

2010-08-29 Thread Manjunath Manohar
it is compiler dependant da..the evaluation of this kind of expressions -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+

[algogeeks] Re: Adobe Question : Convert a number given in base B1 to a number in base B2 without using any intermediate base

2010-08-29 Thread luckyzoner
@Rahul : I know that u are using table of base b2 in base b1 and then dividing the number using the table ...but the real problem is to code it -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@goo

Re: [algogeeks] Re: Will miracle ever print ?

2010-08-29 Thread srinivas reddy
@aravind i think u are right code plzz On Sun, Aug 29, 2010 at 10:59 PM, Aravind wrote: > #define int 1 || > #define data 1 || 1 > > having theses macros will print miracle > if macros are allowed > > On Sun, Aug 29, 2010 at 10:20 PM, Manjunath Manohar < > manjunath.n...@gmail.com> wrote

Re: [algogeeks] Re: Will miracle ever print ?

2010-08-29 Thread Aravind
#define int 1 || #define data 1 || 1 having theses macros will print miracle if macros are allowed On Sun, Aug 29, 2010 at 10:20 PM, Manjunath Manohar < manjunath.n...@gmail.com> wrote: > it will never print..and @ above..the != will never be evaluated ..because > of the short circuiting

Re: [algogeeks] evaluate expression

2010-08-29 Thread Manjunath Manohar
the running time of the algo would be exponential.you need to permute the array with different combinations of the operators.. i can help you with the code for permuting an array.. i hope u get my point.. -- You received this message because you are subscribed to the Google Groups "Algorithm Gee

Re: [algogeeks] Re: Will miracle ever print ?

2010-08-29 Thread Manjunath Manohar
it will never print..and @ above..the != will never be evaluated ..because of the short circuiting && -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this gr

[algogeeks] evaluate expression

2010-08-29 Thread krazee koder
hi all! You r given numbers from 0-9 and one RESULT (R). you can use operators *,/,-,+,""(concatening nos. like 12,123 etc.) ... You must find the possible expression that yields R. Pls post all possible solns fr this...m totally clueless. -- You received this message because you are subscribed

Re: [algogeeks] Re: Will miracle ever print ?

2010-08-29 Thread prasad rao
miracle never print on the screen. Because first preference is == and != after that &&. So data == -data is wrong so (0 && data!=0) is also wrong. On 29 August 2010 21:17, mohit wrote: > i think "never". > > On Aug 27, 10:45 pm, Raj N wrote: > > int data; // Initialize data during run time > >

Re: [algogeeks] Help with Increment Operators in C!

2010-08-29 Thread prasad rao
In printf, the cursor goes to left to right. so x++ + ++x + x++ 5 + 7 +7 = 19. ( Here x=5, then we put 5 in place of first x, after that x will be incremented(post increment) that means x is 6 and we take second x which is pre-increment and hence once again x will be incremented that means x is 7

[algogeeks] how to check a problem p or np complete or incomplete

2010-08-29 Thread mohit verma
hi all, can anyone tell me how can one recognize a given problem whether it is NP complete or incomplete or N complete in some considerable time limit. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to alg

[algogeeks] Re: Will miracle ever print ?

2010-08-29 Thread mohit
i think "never". On Aug 27, 10:45 pm, Raj N wrote: > int data; // Initialize data during run time > if ( data == -data && data!=0) >         printf ("Miracle!!"); > > Will miracle ever print ? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group.

[algogeeks] Re: Adobe Question : Convert a number given in base B1 to a number in base B2 without using any intermediate base

2010-08-29 Thread Ukil
@above Can't you please explain a bit? On Aug 29, 10:15 am, rahul patil wrote: > Check out my solution. Hope u are looking for this, > > Take  a no   136 (base7 = 76 decimal )  convert to base 5 (ans shld be > 301) > > start from left side 1*7^2= 49/5^2 =  1 (rem 24)    - > > | > > ^ >  

Re: [algogeeks] Re: Amazon interview Question (Array yet again!)

2010-08-29 Thread rahul patil
Just read the comments. You will get logic. 1> read global variables 2> start with main 3> read rec (a recursive fn) The main logic is that whether to keep the no in the final no (by decrementing it) or to completely remove it. #include #define SIZE 4 int result[SIZE];/*Array for stori

Re: [algogeeks] Re: Amazon interview Question (Array yet again!)

2010-08-29 Thread gaurav singhal
@ Gene: Sorry I misunderstood the problem. I thought the other operation is of increment rather than decrement... My bad -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To uns

[algogeeks] Re: Amazon interview Question (Array yet again!)

2010-08-29 Thread jagadish
@Rahul Patil: I ran your code on some basic test cases and i found it to be correct! Can you please explain the logic you used to arrive at the solution? Thanks :-) On Aug 29, 12:25 pm, rahul patil wrote: > check out this solution.I think this works correct > will explain logic if u find it c

[algogeeks] Re: Amazon interview Question (Array yet again!)

2010-08-29 Thread rahul patil
check out this solution.I think this works correct will explain logic if u find it correct. #include #define SIZE 4 int result[SIZE]; int final_cost = 10; int curr_ans[SIZE]; void save_arr(int *result) { int i; for (i=0 ;i= 0) { // keep the arr[index] if (arr[index] <= mi