Re: [algogeeks] Re: adobe written round que

2011-07-29 Thread SAMM
Single bit shift... int divide(int n) { n-=1; n>>=1; return n; } On 7/30/11, tech rascal wrote: > hw will u get the ans on repeated subtraction from the sum of the digits?? > I mean if I hv 2 divide 27 by 3 thn first I'll find sum of the digits > i.e, 2+7=9 > then I'll apply repeated subtrac

[algogeeks] Data Structure Question

2011-07-29 Thread Mani Bharathi
Find the ‘n’th node as it appears in the in order traversal of the given tree if each node contains the number of nodes in its subtree as value of node. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visi

Re: [algogeeks] BST Question

2011-07-29 Thread saurabh singh
please give an example. On Sat, Jul 30, 2011 at 12:10 PM, Mani Bharathi wrote: > connect all sibling nodes of a binary search tree > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To view this discussion on the web visit > https:/

Re: [algogeeks] Write C code to check if an integer is a power of 2 or not in a single line?

2011-07-29 Thread Amol Sharma
if ( x&(x-1)==0 ) then number is of forn 2^n else false put a separate check for x=0 as the above will not work for x=0 explanation- take x = 8 =1000 x-1 = 7 =111 clearly x&(x-1) is 0 similarly do for a number which is not 2^n hope this helps !! -- Amol Sharma Third Year Studen

[algogeeks] BST Question

2011-07-29 Thread Mani Bharathi
connect all sibling nodes of a binary search tree -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/GWAhIi6vaxAJ. To post to this group, send email to algogee

Re: [algogeeks] Write C code to check if an integer is a power of 2 or not in a single line?

2011-07-29 Thread tech rascal
thanx for the explanation saurabh On Sat, Jul 30, 2011 at 11:54 AM, ankit sambyal wrote: > If x is the number which is to be checked, > > if (x && !(x & (x-1)) == 0) > then power of 2 > > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" gro

Re: [algogeeks] finding element in rotated array

2011-07-29 Thread Ankur Khurana
above is when the sorted array is in increasing order. On Sat, Jul 30, 2011 at 11:56 AM, Ankur Khurana wrote: > low =lower_bound , high=upper_bound; > int a=arr[low]; > while(low { > mid=(low+high)/2; > if( arr[mid]>a && mid break; //you found the index of distortion > > if(arr[mid]>a) > low=mid+

Re: [algogeeks] finding element in rotated array

2011-07-29 Thread Ankur Khurana
low =lower_bound , high=upper_bound; int a=arr[low]; while(lowa && mida) low=mid+1; else high=mid-1; } On Sat, Jul 30, 2011 at 11:46 AM, saurabh singh wrote: > Look for the spike...that is the index where the sorted property is > disturbed. > > > On Sat, Jul 30, 2011 at 11:44 AM, tech rascal wr

Re: [algogeeks] 32 bit?

2011-07-29 Thread rajeev bharshetty
If pointer size is 4bytes then it is 32 bit machine and if 8 bytes it is 64 bit On Sat, Jul 30, 2011 at 11:51 AM, Nikhil Gupta wrote: > How do you find out if a machine is 32 bit or 64 bit? > > I was thinking since the size of pointer variable is different in the 2 > configurations, we can declar

Re: [algogeeks] Write C code to check if an integer is a power of 2 or not in a single line?

2011-07-29 Thread ankit sambyal
If x is the number which is to be checked, if (x && !(x & (x-1)) == 0) then power of 2 -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send emai

Re: [algogeeks] Write C code to check if an integer is a power of 2 or not in a single line?

2011-07-29 Thread saurabh singh
if(t&&!(t&(t-1)) return true; reason: any power of two will be of form 00100 that is 0 at only one position.If you subtract 1 from it that will make it of the form 11 that is ones at all positions to the right except the position where there is 1 in the original number.If you take and now you

Re: [algogeeks] Write C code to check if an integer is a power of 2 or not in a single line?

2011-07-29 Thread Nikhil Gupta
if(!(num & (num - 1)) && num) { // Power of 2! } On Sat, Jul 30, 2011 at 11:49 AM, tech rascal wrote: > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe

[algogeeks] 32 bit?

2011-07-29 Thread Nikhil Gupta
How do you find out if a machine is 32 bit or 64 bit? I was thinking since the size of pointer variable is different in the 2 configurations, we can declare a pointer and use sizeof() Will that work? Any other suggestions? -- Nikhil Gupta -- You received this message because you are subscribed

[algogeeks] Write C code to check if an integer is a power of 2 or not in a single line?

2011-07-29 Thread tech rascal
-- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at ht

Re: [algogeeks] finding element in rotated array

2011-07-29 Thread saurabh singh
Look for the spike...that is the index where the sorted property is disturbed. On Sat, Jul 30, 2011 at 11:44 AM, tech rascal wrote: > how to find distortion using binary search?? > > > On Sat, Jul 30, 2011 at 11:34 AM, Mohit Goel wrote: > >> yes ..u r right ...thnks... >> >> -- >> You received

Re: [algogeeks] finding element in rotated array

2011-07-29 Thread tech rascal
how to find distortion using binary search?? On Sat, Jul 30, 2011 at 11:34 AM, Mohit Goel wrote: > yes ..u r right ...thnks... > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegro

Re: [algogeeks] finding element in rotated array

2011-07-29 Thread Mohit Goel
yes ..u r right ...thnks... -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more opti

[algogeeks] rajeev bharshetty wants to chat

2011-07-29 Thread rajeev bharshetty
--- rajeev bharshetty wants to stay in better touch using some of Google's coolest new products. If you already have Gmail or Google Talk, visit: http://mail.google.com/mail/b-fa8b2f68fb-7b53be141f-z1723Z4LtlasPTsvQH98EBXXl70 You

Re: [algogeeks] finding element in rotated array

2011-07-29 Thread Ankur Khurana
it's rotation right , so no matter how many times you rotate , it will sorted except for one distortion. no ? On Sat, Jul 30, 2011 at 11:12 AM, Mohit Goel wrote: > but this works ,if array is rotated multiple times ,around different > pivots. > > -- > You received this message because you ar

Re: [algogeeks] finding element in rotated array

2011-07-29 Thread Mohit Goel
but this works ,if array is rotated multiple times ,around different pivots. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to a

Re: [algogeeks] finding element in rotated array

2011-07-29 Thread Ankur Khurana
find the distrotion first in the array using binary search . now you have the last element where the array was rotated. So pick your range, it will be either left or right subarray. Binary search in that. log(n). On Sat, Jul 30, 2011 at 11:01 AM, Mohit Goel wrote: > Given a sorted a

[algogeeks] finding element in rotated array

2011-07-29 Thread Mohit Goel
Given a sorted array of n integers that has been rotated an unknown number of times, give an O(log n) algorithm that finds an element in the array You may assume that the array was originally sorted in increasing order EXAMPLE: Inp

Re: [algogeeks] Re: adobe written round que

2011-07-29 Thread tech rascal
hw will u get the ans on repeated subtraction from the sum of the digits?? I mean if I hv 2 divide 27 by 3 thn first I'll find sum of the digits i.e, 2+7=9 then I'll apply repeated subtraction on 9, so hw will i reach to the ans?? On Sat, Jul 30, 2011 at 10:05 AM, nivedita arora < vivaciousni

Re: [algogeeks] String vs char array

2011-07-29 Thread sanjay ahuja
string class also stores the length of the string associated with it. When the string is printed, it prints it till the length but char array does not store any length variable. On Sat, Jul 30, 2011 at 10:36 AM, Grapher wrote: > string str("Hello"); > int main() > { >    str[3]=0; >    cout< } >

[algogeeks] String vs char array

2011-07-29 Thread Grapher
string str("Hello"); int main() { str[3]=0; cout

[algogeeks] Re: adobe written round que

2011-07-29 Thread nivedita arora
@brijesh- itoa basically converts integer to string ..we are using the fact tht a number is multiple of 3 if its sum is multiple of 3 . we have int as string and we can traverse it ..for each character apply int sum+=*c-'0' (ankur missed the star :P) then on sum we use repeated subtraction...i ho

Re: [algogeeks] Re: adobe written round que

2011-07-29 Thread ananth sharma
shift the number to left two times and subtract once... I.e. Int x=num; x=x<<2; x-=num; On 7/30/11, brijesh wrote: > @ankur I didnt get this... could u or anyone please elaborate! > > On Jul 30, 12:43 am, Ankur Khurana wrote: >> when you use itoa , what you get is a string. get the sum of all t

Re: [algogeeks] Re: self referential struct. Contd.

2011-07-29 Thread tech rascal
can anyone explain in detail .how structure padding is advantageous??? On Fri, Jul 29, 2011 at 10:28 PM, Rohit Srivastava wrote: > padding based on the bit interleaving(low order) which is basically > hardware dependent. > > > On Fri, Jul 29, 2011 at 10:10 PM, Puneet Gautam > wrote: > >> Tha

Re: [algogeeks] Re: binary search tree question!!!!

2011-07-29 Thread ankit sambyal
Here the required program : void findkthSmallest(Node *root,int k) { Node *stack[100]; int top=-1,count=0; Node *temp; stack[++top]=root; /*First we will find the minimum node*/ temp=root; while(temp->left != NULL) { stack[++top]=temp->left; temp->left=

Re: [algogeeks] Re: Novell - Puzzle

2011-07-29 Thread Reynald Suz
Thank ya shiv, agarwal and Anders. On Sat, Jul 30, 2011 at 8:10 AM, Anders Ma wrote: > anders@anders-Satellite-U400:~/puzzle$ cat novel_she_calf.c > #include > > /* > iIf a cow produces its first she-calf at age two years and after that > produces another single she-calf every year, how many sh

Re: [algogeeks] Re: binary search tree question!!!!

2011-07-29 Thread Poised~
The only way remains is to use the iterative method of traversing a BST in in-order (you have to use a Stack to keep track of father). The place where you print the value of the node, put a condition before that if (!(--k)){ print value_of_node; } in the outermost loop where you check "while(

Re: [algogeeks] Directi Ques

2011-07-29 Thread Rajeev Kumar
@All : pls suggest an algo. On Fri, Jul 29, 2011 at 10:21 AM, sukhmeet singh wrote: > *http://code.google.com/codejam/contest/dashboard?c=32001* > > > On Fri, Jul 29, 2011 at 10:43 PM, swetha rahul wrote: > >> Hi, >> given a complete binary tree (either a node is a leaf n

Re: [algogeeks] kth number of a large number of data

2011-07-29 Thread Mahesh Gunda
I think, Medians of median algo for this. On Mon, Oct 19, 2009 at 3:53 PM, ankur aggarwal wrote: > If you have a large number of data which are stored on 100 distributed > computers, unsorted, how can you compute the kth number of all the data? > > > --~--~-~--~~~---~

Re: [algogeeks] Re: Novell - Puzzle

2011-07-29 Thread Anders Ma
anders@anders-Satellite-U400:~/puzzle$ cat novel_she_calf.c #include /* iIf a cow produces its first she-calf at age two years and after that produces another single she-calf every year, how many she-calves are there after 12 years? assuming none die. */ unsigned int she_calves(unsigned int year

[algogeeks] Re: adobe written round que

2011-07-29 Thread brijesh
@ankur I didnt get this... could u or anyone please elaborate! On Jul 30, 12:43 am, Ankur Khurana wrote: > when you use itoa , what you get is a string. get the sum of all the digits > , using c-'0' and then use repeated subtraction . . . > > On Sat, Jul 30, 2011 at 1:01 AM, sukhmeet singh wrote:

Re: [algogeeks] Re: adobe written round que

2011-07-29 Thread Sudhir mishra
int divideby3 (int num) { int sum = 0; while (num > 3) { sum += num >> 2; num = (num >> 2) + (num & 3); } if (num == 3) ++sum; return sum; } Thanks & Regards...* รυ∂んเя мเรんяค* -- You received this message because you are subscribed to the Google Groups "Algor

Re: [algogeeks] Decimal to any base

2011-07-29 Thread aditi garg
yeah i got it thanx :) On Sat, Jul 30, 2011 at 3:25 AM, Kamakshii Aggarwal wrote: > it is selecting ' m 'th word from the string.. > > On Sat, Jul 30, 2011 at 3:06 AM, aditi garg wrote: > >> int main() >> { decimal_to_anybase(10, 2); >> decimal_to_anybase(255, 16); >> getch(); } >> decimal_to_

Re: [algogeeks] Re: adobe written round que

2011-07-29 Thread aditi garg
ur expression forms 4/8=1/2 and not 1/3... On Sat, Jul 30, 2011 at 3:18 AM, Amit wrote: > well,well,well... > a=x>>1; > b=x>>2; > c=(a+b)>>1; > d=x>>3; > x=c+d; > 1/3 = 3/9 = ((1/2)+(1/4))/2 + 1/8 > > > On Jul 30, 1:37 am, nivedita arora > wrote: > > hmm ok got it . ..i can take gt sum of di

Re: [algogeeks] Decimal to any base

2011-07-29 Thread Kamakshii Aggarwal
it is selecting ' m 'th word from the string.. On Sat, Jul 30, 2011 at 3:06 AM, aditi garg wrote: > int main() > { decimal_to_anybase(10, 2); > decimal_to_anybase(255, 16); > getch(); } > decimal_to_anybase(int n, int base) > { int i, m, digits[1000], flag; i=0; > printf("\n\n[%d] converted t

[algogeeks] Re: adobe written round que

2011-07-29 Thread Amit
well,well,well... a=x>>1; b=x>>2; c=(a+b)>>1; d=x>>3; x=c+d; 1/3 = 3/9 = ((1/2)+(1/4))/2 + 1/8 > On Jul 30, 1:37 am, nivedita arora wrote: > hmm ok got it . ..i can take gt sum of digits without having the > number as string as well . i din exactly gt the whole point of using > strings. > they

[algogeeks] Decimal to any base

2011-07-29 Thread aditi garg
int main() { decimal_to_anybase(10, 2); decimal_to_anybase(255, 16); getch(); } decimal_to_anybase(int n, int base) { int i, m, digits[1000], flag; i=0; printf("\n\n[%d] converted to base [%d] : ", n, base); while(n) { m=n%base; digits[i]="0123456789abcdefghijklmnopqrstuvwxyz"[m] ; n=n/base;

[algogeeks] Re: adobe written round que

2011-07-29 Thread nivedita arora
hmm ok got it . ..i can take gt sum of digits without having the number as string as well . i din exactly gt the whole point of using strings. they shud hv mentioned it explicitly i guess . . though thanks ankur On Jul 30, 1:15 am, Ankur Khurana wrote: > you shouldn't be using itoa anyways. It is

Re: [algogeeks] Makemytrip.com

2011-07-29 Thread sukhmeet singh
CTC ??? On Thu, Jul 28, 2011 at 10:22 PM, Raman Gugnani wrote: > Hi Can anyone please tell me where from and how to prepare for > MAKEMYTRIP.COM intern test..It is coming to NIT Kurukshetra campus > next week..! Also tell how this company is Good /Bad...?? > > -- > You received this message becau

Re: [algogeeks] adobe written round que

2011-07-29 Thread Ankur Khurana
you shouldn't be using itoa anyways. It is not a part of ANSI C. you might like to use sprintf . you can search for reference on cplusplus.com On Sat, Jul 30, 2011 at 1:36 AM, aditi garg wrote: > @Ankur: I dont know how to use itoa function...can u please write a small > code...for eg in dis ques

Re: [algogeeks] adobe written round que

2011-07-29 Thread aditi garg
@Ankur: I dont know how to use itoa function...can u please write a small code...for eg in dis ques only can u tell me how to use itoa to get sum... On Sat, Jul 30, 2011 at 1:13 AM, Ankur Khurana wrote: > when you use itoa , what you get is a string. get the sum of all the digits > , using c-'0'

Re: [algogeeks] Re: plz give some efficient method to find out if a point lies inside or outside the triangle?

2011-07-29 Thread Arun Vishwanathan
@don: is what I have mentioned above almost the same as the method u r saying? On Fri, Jul 29, 2011 at 9:16 PM, Don wrote: > You just need some comparison which determines if they are very close > to equal. You can't expect them to be exactly equal in all 64 bits. > Something like this should be

Re: [algogeeks] adobe written round que

2011-07-29 Thread Ankur Khurana
when you use itoa , what you get is a string. get the sum of all the digits , using c-'0' and then use repeated subtraction . . . On Sat, Jul 30, 2011 at 1:01 AM, sukhmeet singh wrote: > repeated subtraction !! > > On Sat, Jul 30, 2011 at 12:52 AM, nivedita arora < > vivaciousnived...@gmail.com>

Re: [algogeeks] adobe written round que

2011-07-29 Thread sukhmeet singh
repeated subtraction !! On Sat, Jul 30, 2011 at 12:52 AM, nivedita arora < vivaciousnived...@gmail.com> wrote: > Without using /,% and * operators. write a function to divide a number > by 3. itoa() function is available. > > all i cn thnk of is to use shift operator and addition , x/3=e^(logx-

[algogeeks] adobe written round que

2011-07-29 Thread nivedita arora
Without using /,% and * operators. write a function to divide a number by 3. itoa() function is available. all i cn thnk of is to use shift operator and addition , x/3=e^(logx- log3) or repetitive subtraction but none of them uses itoa() ..ne idea how its done? thnks ! -- You received this mes

Re: [algogeeks] Re: Testcases

2011-07-29 Thread hary rathor
oh! sorry : if(c^2 a^2+b^2) obtuse angle -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com.

Re: [algogeeks] Re: Testcases

2011-07-29 Thread rajeev bharshetty
@hary are the conditions same for both acute and obtuse triangles as you mentioned ??? On Sat, Jul 30, 2011 at 12:46 AM, hary rathor wrote: > > if(c^2 if(c^2 =a^2+b^2) right angle > if(c^2 > NOT : ^ is used for power operation > > -- > You received this message because you are subscribed to t

Re: [algogeeks] Re: Testcases

2011-07-29 Thread hary rathor
if(c^2 http://groups.google.com/group/algogeeks?hl=en.

[algogeeks] Re: plz give some efficient method to find out if a point lies inside or outside the triangle?

2011-07-29 Thread Don
You just need some comparison which determines if they are very close to equal. You can't expect them to be exactly equal in all 64 bits. Something like this should be fine: bool isClose(double a, double b) { const double epsilon = 1.001; return (a < b*epsilon) && (b < a*epsilon); } (Note

[algogeeks] SDET- Amazon

2011-07-29 Thread Rohit jalan
Hi All, Anyone having an idea about the Amazon interview questions for the position SDET(Software Development Engineer in Test) ?? -- Regards : ROHIT JALAN -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email t

[algogeeks] Re: Testcases

2011-07-29 Thread Maddy
If the three sides are a,b,c 1. sum of length of any two sides of a triangle, always exceeds the third side. So, this can be taken as the first test case, to see if a,b,c form a triangle. 2.if any of the two sides a,b,c are equal- its isoceles triangle 3.in an obtuse triangle, sum of square of 2 s

Re: [algogeeks] C output 3

2011-07-29 Thread prashant bhutani
fffe is two's complement of 2. Let me explain for fe and you can extrapolate it with other f's. f =15, e =14. fe = 1110, ~fe = 0001, ~fe+1 = 0010 = 2 which gives your answer. Thanks & Regards, Prashant Bhutani Senior Undergraduate Computer Science & Engineering (B.Tech) Institute o

Re: [algogeeks] problem at line number 12

2011-07-29 Thread Ankur Khurana
AFAIK , it is adaptation of gcc standards, which is the problem with mingw as well . So i use ideone to check my answer as it uses spoj engine which is considered more standard. I guess that is the reason, i cant think of other On Fri, Jul 29, 2011 at 11:51 PM, rajeev bharshetty wrote: > @ankur

Re: [algogeeks] C output 3

2011-07-29 Thread Ankur Khurana
i figured it out. I didnt know before that is was in 2's complement form . On Fri, Jul 29, 2011 at 11:53 PM, sukhmeet singh wrote: > I couldn't understand the problem .. u have used %x as indentifier that why > it is so > > On Fri, Jul 29, 2011 at 11:37 PM, Ankur Khurana > wrote: > >> Please exp

Re: [algogeeks] problem at line number 12

2011-07-29 Thread Ankur Khurana
Thanks for pointing that out, my apologies . . . On Fri, Jul 29, 2011 at 11:53 PM, rajeev bharshetty wrote: > @ankur : Dude I think you compiled in ideone as C++ language but it is C :) > http://ideone.com/HZhHu > > > On Fri, Jul 29, 2011 at 11:51 PM, rajeev bharshetty > wrote: > >> @ankur: Bu

Re: [algogeeks] C output 3

2011-07-29 Thread sukhmeet singh
I couldn't understand the problem .. u have used %x as indentifier that why it is so On Fri, Jul 29, 2011 at 11:37 PM, Ankur Khurana wrote: > Please explain the output, that why is it in that form in hexadecimal form > > > #include > > int main() > { > printf("%d %x",-1<<1,-1<<1); > return

Re: [algogeeks] problem at line number 12

2011-07-29 Thread rajeev bharshetty
@ankur : Dude I think you compiled in ideone as C++ language but it is C :) http://ideone.com/HZhHu On Fri, Jul 29, 2011 at 11:51 PM, rajeev bharshetty wrote: > @ankur: But the same above code wont show any error on my gcc 4.3.2 running > on Open Suse 11.4 > > > On Fri, Jul 29, 2011 at 11:48

Re: [algogeeks] C output 3

2011-07-29 Thread aditi garg
this is bec -1 in hexadecimal is On Fri, Jul 29, 2011 at 11:37 PM, Ankur Khurana wrote: > Please explain the output, that why is it in that form in hexadecimal form > > > #include > > int main() > { > printf("%d %x",-1<<1,-1<<1); > return 0; > } > > > output : > > -2 fffe > > >

Re: [algogeeks] Re: plz give some efficient method to find out if a point lies inside or outside the triangle?

2011-07-29 Thread prashant bhutani
Yeah, the comparison of two floats will be a problem as the behaviour is undefined and depends on the machine architecture and compiler. Thanks & Regards, Prashant Bhutani Senior Undergraduate Computer Science & Engineering (B.Tech) Institute of Technology - BHU (IT-BHU) Varanasi-221005 On Fri,

Re: [algogeeks] problem at line number 12

2011-07-29 Thread rajeev bharshetty
@ankur: But the same above code wont show any error on my gcc 4.3.2 running on Open Suse 11.4 On Fri, Jul 29, 2011 at 11:48 PM, Ankur Khurana wrote: > http://ideone.com/OaCDR > > > On Fri, Jul 29, 2011 at 11:45 PM, rajeev bharshetty > wrote: > >> @ankur :which compiler are u using?? >> >> >

Re: [algogeeks] Programming Puzzle!!!!!!!

2011-07-29 Thread Ankur Khurana
isn't it knapsack problem ? On Fri, Jul 29, 2011 at 4:29 PM, ankit sambyal wrote: > @aman: My mistake. > set* memo[0]=0* > > The revised algo is : > > > Algo: > 1. int memo[S] > 2. initialize all its elements to infinite. > * > 3.memo[0]=0* > > 4.for i=1 to S > for j=0 to N-1 > if(

[algogeeks] Amazon

2011-07-29 Thread Agyat
I heard that Amazon visited recently NIT warangal. NIT warangal guys, please post the questions.I also heard that there were different set of questions.plz guys post these question...at least post the written test questions... -- You received this message because you are subsc

Re: [algogeeks] problem at line number 12

2011-07-29 Thread Ankur Khurana
http://ideone.com/OaCDR On Fri, Jul 29, 2011 at 11:45 PM, rajeev bharshetty wrote: > @ankur :which compiler are u using?? > > > On Fri, Jul 29, 2011 at 11:39 PM, Ankur Khurana > wrote: > >> @rajeev: your code gives compilation error. >> >> >> On Fri, Jul 29, 2011 at 11:39 PM, Ankur Khurana > > w

Re: [algogeeks] problem at line number 12

2011-07-29 Thread rajeev bharshetty
@ankur :which compiler are u using?? On Fri, Jul 29, 2011 at 11:39 PM, Ankur Khurana wrote: > @rajeev: your code gives compilation error. > > > On Fri, Jul 29, 2011 at 11:39 PM, Ankur Khurana > wrote: > >> no , >> n[0] is *(n+0) >> so actually n is being dereferenced here .Check the basci diff >

Re: [algogeeks] Re: MS question

2011-07-29 Thread rajeev bharshetty
Test cases for MSN Search Engine 1 : Check for auto completion feature (The auto completion based on the prefix should provide suggestions for the most searched keyword with that prefix) . 2 : The spelling correction feature which shows as to what the user actually meant. This should be highly

Re: [algogeeks] Re: plz give some efficient method to find out if a point lies inside or outside the triangle?

2011-07-29 Thread tech rascal
area of 3 triangles being formed by joining the point to 3 vertices can be float n when we add the 3 areas, the sum wud also be float. and this is to b compared with original area don't u think the problem wud arise in comparing the floats? wud that give right ans?? On Fri, Jul 29, 2011 at 9:06 PM

Re: [algogeeks] problem at line number 12

2011-07-29 Thread Ankur Khurana
@rajeev: your code gives compilation error. On Fri, Jul 29, 2011 at 11:39 PM, Ankur Khurana wrote: > no , > n[0] is *(n+0) > so actually n is being dereferenced here .Check the basci diff > > p is a pointer , but n is a pointer to a pointer. > > > On Fri, Jul 29, 2011 at 11:34 PM, Arshad Alam wr

Re: [algogeeks] problem at line number 12

2011-07-29 Thread Ankur Khurana
no , n[0] is *(n+0) so actually n is being dereferenced here .Check the basci diff p is a pointer , but n is a pointer to a pointer. On Fri, Jul 29, 2011 at 11:34 PM, Arshad Alam wrote: > wow great... but why it is so yaar? > ptr=n and ptr=n[0] is same na? > > > On Fri, Jul 29, 2011 at 11:27 P

Re: [algogeeks] Re: binary search tree question!!!!

2011-07-29 Thread sukhmeet singh
no it wouldn't try finding a tree where no left exist in the root On Fri, Jul 29, 2011 at 2:14 PM, shiv narayan wrote: > would it work > temp=root; > for(int i=0;i { > temp=temp->left; > } > > On Jul 29, 10:48 am, sunny agrawal wrote: > > Node* x = TREE_MINIMUM(root); > > for(int i = 0; i <

[algogeeks] C output 3

2011-07-29 Thread Ankur Khurana
Please explain the output, that why is it in that form in hexadecimal form #include int main() { printf("%d %x",-1<<1,-1<<1); return 0; } output : -2 fffe -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group,

Re: [algogeeks] problem at line number 12

2011-07-29 Thread Arshad Alam
wow great... but why it is so yaar? ptr=n and ptr=n[0] is same na? On Fri, Jul 29, 2011 at 11:27 PM, rajeev bharshetty wrote: >#include > >void main() > { > int n[3][3]= { > 2,4,3, >6,8,5, > 3,5,1 >

Re: [algogeeks] problem at line number 12

2011-07-29 Thread Ankur Khurana
try this #include void main() { int n[3][3]= { 2,4,3, 6,8,5, 3,5,1 }; int i,*ptr; ptr= (int *) n; for(i=0;i<=8;i++) printf("\n%d",*(ptr+i)); } On Fri, Jul 29,

Re: [algogeeks] problem at line number 12

2011-07-29 Thread rajeev bharshetty
#include void main() { int n[3][3]= { 2,4,3, 6,8,5, 3,5,1 }; int i,*ptr; ptr= n; for(i=0;i<=8;i++) printf("\n%d",*(ptr+i)); } In gcc 4.3.2 no error ,it is j

[algogeeks] problem at line number 12

2011-07-29 Thread Arshad Alam
what's the problem with line number 12? 1#include 2#include 3void main() 4 { 5clrscr(); 6int n[3][3]= { 7 2,4,3, 8 6,8,5, 9 3,5,1 10 }; 11 int i,*ptr; 12 p

Re: [algogeeks] Re: MS question

2011-07-29 Thread vaibhav agarwal
what has palindrome to do with this? On Mon, Jul 18, 2011 at 1:11 AM, swetha rahul wrote: > Thanks everyone!! > > > On Sun, Jul 17, 2011 at 10:56 PM, ankit sambyal wrote: > >> Check for case senstivity also: >> eg: "Madam" and "madam" both are palindromes. >> >> >> Also for clarify with the int

Re: [algogeeks] Directi Ques

2011-07-29 Thread sukhmeet singh
*http://code.google.com/codejam/contest/dashboard?c=32001* On Fri, Jul 29, 2011 at 10:43 PM, swetha rahul wrote: > Hi, > given a complete binary tree (either a node is a leaf node or > has two children) > > every leaf node has value 0 or 1. > every internal node has value as the AND g

Re: [algogeeks] static array

2011-07-29 Thread SREENU NAIK
0 0 0 0 for this qu On Fri, Jul 29, 2011 at 10:35 PM, Kamakshii Aggarwal wrote: > yes it works for arrays also > > > On Fri, Jul 29, 2011 at 10:11 PM, sabitha k wrote: > >> i thought only static variables will be set zero. Even for array too this >> works? >> -- >> *sabitha* >> >> -- >> You rec

Re: [algogeeks] The Google Resume

2011-07-29 Thread Deoki Nandan
I heartly thanx On Fri, Jul 29, 2011 at 10:39 PM, !!!p@[/\]@n!!! < ssrpavan.pavanku...@gmail.com> wrote: > > > On Wed, Jul 27, 2011 at 12:56 AM, Anand Saha wrote: > >> Here: http://goo.gl/pDG5s >> >> (Yes, that's the correct link) >> -- >> >> >> >> On Wed, Jul 27, 2011 at 1:18 PM, malay chakraba

[algogeeks] Directi Ques

2011-07-29 Thread swetha rahul
Hi, given a complete binary tree (either a node is a leaf node or has two children) every leaf node has value 0 or 1. every internal node has value as the AND gate or OR gate. you are given with the tree and a value V. you have to output the minimum number of flips (AND to OR or OR to

Re: [algogeeks] static array

2011-07-29 Thread Kamakshii Aggarwal
yes it works for arrays also On Fri, Jul 29, 2011 at 10:11 PM, sabitha k wrote: > i thought only static variables will be set zero. Even for array too this > works? > -- > *sabitha* > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > T

Re: [algogeeks] Re: self referential struct. Contd.

2011-07-29 Thread Rohit Srivastava
padding based on the bit interleaving(low order) which is basically hardware dependent. On Fri, Jul 29, 2011 at 10:10 PM, Puneet Gautam wrote: > Thanks guys...so much...!! > > On 7/29/11, nullpointer wrote: > > #include > > #include > > struc MyStructA { > > > > char a; > > char b; > > int c;

Re: [algogeeks] static array

2011-07-29 Thread sabitha k
i thought only static variables will be set zero. Even for array too this works? -- *sabitha* -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, se

Re: [algogeeks] Re: self referential struct. Contd.

2011-07-29 Thread Puneet Gautam
Thanks guys...so much...!! On 7/29/11, nullpointer wrote: > #include > #include > struc MyStructA { > > char a; > char b; > int c; > }; > > struct MyStructB { > char a; > int c; > char b; > }; > > int main(void) { > > struct MyStructA A; > struct MyStructB B; > > int sizeA = sizeof(struct

Re: [algogeeks]

2011-07-29 Thread Puneet Gautam
@vaibhav :Cool ...!! thanks buddy..! On 7/29/11, vaibhav shukla wrote: > If u have 2GB of data file which has one string per line and u have to sort > it, and X MB of memory is available.then divide the file into 'K' chunks of > X MB each. Bring each chunk into memory and sort lines by any usual

Re: [algogeeks]

2011-07-29 Thread ankit sambyal
@anika: Here is the iterative code: void iter_mirror(Node *root) { if(root==NULL) return; Node *stack[100]; Node *temp,*temp1; int top=-1; stack[++top]=root; while(top!=-1) { temp=stack[top]; temp1=temp->left; temp->left=temp->right;

Re: [algogeeks] static array

2011-07-29 Thread Arshad Alam
ok thanx brother i got now On Fri, Jul 29, 2011 at 9:07 PM, sagar pareek wrote: > During declaration of static variables.. after assigning memory to all the > elements it initialize *ALL THE MEMORY ALLOTTED *members with zero...* * > > On Fri, Jul 29, 2011 at 8:09 PM, Arshad Alam wrote

Re: [algogeeks] static array

2011-07-29 Thread sagar pareek
During declaration of static variables.. after assigning memory to all the elements it initialize *ALL THE MEMORY ALLOTTED *members with zero...* * On Fri, Jul 29, 2011 at 8:09 PM, Arshad Alam wrote: > > Yes I agree static variables initialises with 0 but 0 will be at the very > first position o

[algogeeks] Re: plz give some efficient method to find out if a point lies inside or outside the triangle?

2011-07-29 Thread Don
That should work, but I'd bet that my method is faster. Don On Jul 29, 6:02 am, Udit Gupta wrote: > Join the given point with all the vertices of the triangle and calculate the > area of each of the three sub-triangles thus formed > now compare the area of original triangle with the sum of the ar

[algogeeks] Re: permutation of string with repeated characters...

2011-07-29 Thread amit karmakar
there was an typo, if mk array is *not* there backtracking will try like On Jul 29, 7:13 pm, amit karmakar wrote: > The seen array filters out the characters which are available for > filling a particular position. > The mk array makes sure that we choose only one of the repeated > characters. >

[algogeeks] Re: Question

2011-07-29 Thread Anika Jain
i also feel the point of kiddle is ryt.. can anybody plz explain more On Jul 26, 12:18 am, SkRiPt KiDdIe wrote: > How much time does he reach home is a bad question to ask. > > Say i walk 90-x minutes before i meet my driver.If i had walked x more > minutes the driver would have reached my office

Re: [algogeeks] doubt in checking if 2 strings are anagrams

2011-07-29 Thread saurabh singh
Things can go very bad in case the string length is large and mostly of non priniting chars. and wat if there are chars with negative ascii value?does ur logic handles this situation?I doubt it does, On Fri, Jul 29, 2011 at 8:21 PM, snehi jain wrote: > no problem .. > but can u find a bug in thi

Re: [algogeeks] doubt in checking if 2 strings are anagrams

2011-07-29 Thread snehi jain
no problem .. but can u find a bug in this technique .. On Fri, Jul 29, 2011 at 8:17 PM, saurabh singh wrote: > ignore above status...i was looking at two problems > simulataneously...posted on the wrong one... > apologies...really its embarrasing. > > On Fri, Jul 29, 2011 at 8:11 PM, snehi jain

Re: [algogeeks] doubt in checking if 2 strings are anagrams

2011-07-29 Thread saurabh singh
ignore above status...i was looking at two problems simulataneously...posted on the wrong one... apologies...really its embarrasing. On Fri, Jul 29, 2011 at 8:11 PM, snehi jain wrote: > thanks .. > @siddhartha : i know the hashing technique ... and the problem of longer > strings can be reduced

[algogeeks] Re: constraint programming

2011-07-29 Thread hafsainfo
thank you On 29 juil, 06:32, pschaus wrote: > I'm not familiar with Choco in particular but you are probably trying > to post an "element" constraint. > Make sure that the index variable has a domain inside the range of the > array on which you apply the element (-1 should not be in the domain).

Re: [algogeeks] doubt in checking if 2 strings are anagrams

2011-07-29 Thread snehi jain
thanks .. @siddhartha : i know the hashing technique ... and the problem of longer strings can be reduced by subtracting a large constant value from the ASCII value of all the characters .. and its not only with cubes even if u add squares of ascii values ... i think it will work . @saurabh : in w

Re: [algogeeks] static array

2011-07-29 Thread Arshad Alam
Yes I agree static variables initialises with 0 but 0 will be at the very first position of the array, so what about second, third ... positions of array..why all those are also 0 but it should be any garbage value... please clarify it. On Fri, Jul 29, 2011 at 7:38 PM, sagar pareek wrote: > 0 0

  1   2   >