[algogeeks] Re: DeShaw Question....tough One

2010-09-06 Thread luckyzoner
In O(n^2) eg. #include #include using namespace std; int a[]={9,8,10,15,6,22,23,4,111,112}; int p[10]={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; int m[10]; int main() { int max, pos, i,j; for(i=9; i>=0; i--) { for(j=i+1; j<10; j++) { if(a[i]http://groups.google.com/

[algogeeks] Re: find duplicate and missing element

2010-09-01 Thread luckyzoner
According to me we can apply the equatin method : Let the missing number be y. Let the duplicated no. be x. 1. then find the product of the 1 to 100 and the sum 1 to 100 :A Product would be of the form...1 *2*3x*..y*100 : B Sum : 1+2+3.+x+y.+100 2. find the prduct

[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

[algogeeks] Re: To sort an array of 0,1,2

2010-08-23 Thread luckyzoner
You can refer to this sample code i had tried to sort in a single pass: #include #include using namespace std; int main() { int a = 0, b=1, c=9; int s[10]= { 2,1,0,1,1,0,2,1,0,1}; while(ab) c--; if(!(a>=b) && !(b>=c)) { if(s[b]==0)

[algogeeks] Re: Adobe Questions

2010-08-21 Thread luckyzoner
to traverse the tree in a spiral manner... 1. Insert the root into stack. 2. then in a loop check not both stack and queue are empty 3. { while(stack not empty) { node =pop(stack); coutleft); insertintoqueue(node

[algogeeks] Re: Adobe Questions

2010-08-20 Thread luckyzoner
SPIRAL Traversal a /\ b c /\ /\ d e f g Output : abcgfed -- 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

[algogeeks] Re: Adobe Questions

2010-08-20 Thread luckyzoner
With reference to the first question...I would say that both the statements were given seperately. The answer to the question is : Hello Hello...as i have tried it out. The reason for the output as i think is that the class functions are allocated the memory even if no object of the class has been

[algogeeks] Re: Adobe Questions

2010-08-19 Thread luckyzoner
With reference to the 2nd question i would lyk to add that the array size is not 3 but any numberwhat i meant to say was that the array nly contains 0,1,2 and no other number...and with reference to the 1st question it should be noted that there is no explicitly defined constructors involved wi

[algogeeks] Adobe Questions

2010-08-19 Thread luckyzoner
1. Suppose a class A is given as : class A { public : void print() { cout<<"Hello"; } } int main() { A * a; A* b = NULL; a->print(); b->print();

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

2010-08-18 Thread luckyzoner
I would again say that you don't have to use any intermediate base while converting. -- 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 t

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

2010-08-17 Thread luckyzoner
I had proposed an algorithm of repeatedly subtracting 1 from the given number and subsequently adding 1 to the new number initialised to 0, till the given number becomes 0. However as soon as the digit reaches the limit , the digit becomes 0 and you add 1 to the next digit. I was not able to code i