Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
@sagar: The question says Algo should be in place. So use of an array to print the right border of tree is not advisable. We can do it recursively without using an array also . On Sat, Jul 16, 2011 at 10:48 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed twice. otherwise it is fine. On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.comwrote: please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.comwrote: Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.comwrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.comwrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.comwrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] What is the output of the following program? Why?
i wasnt sure abt the first part of it. the one with multiple initializations ... :P On Sun, Jul 17, 2011 at 3:09 AM, sagar pareek sagarpar...@gmail.com wrote: Well shubham if you know about the unions very well then why u asked this question? On Sun, Jul 17, 2011 at 2:27 AM, Shubham Maheshwari shubham.veloc...@gmail.com wrote: :D On Sun, Jul 17, 2011 at 2:24 AM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: @shubham:yes u r right.thanks :) On Sun, Jul 17, 2011 at 2:12 AM, Shubham Maheshwari shubham.veloc...@gmail.com wrote: @Kamakshii: thats probably becuz a union has a common memory location, accessed by all its members. so, the value '100' is treated as an int by 'a', as a char array by 'b' and as a float by 'c'. I thnk i read this read tis somewhere sometime back. ... so aint completely sure abt it. On Sun, Jul 17, 2011 at 2:08 AM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: u can always retrieve that value from the union that has been assigned last.therefore u get correct answer only for x.c in the case of union y y.a=100 and so the output but am not sure why y.b is printing character equivalent of 100. On Sun, Jul 17, 2011 at 1:58 AM, Shubham Maheshwari shubham.veloc...@gmail.com wrote: you mean to say .. the ques is wrong ... or what ...!! On Sun, Jul 17, 2011 at 1:54 AM, sagar pareek sagarpar...@gmail.comwrote: I think you must first read about unions and the differences between union and structures :) On Sun, Jul 17, 2011 at 1:48 AM, Shubham Maheshwari shubham.veloc...@gmail.com wrote: union Data Type What is the output of the following program? Why? #include main() { typedef union { int a; char b[10]; float c; } Union; Union x,y = {100}; x.a = 50; strcpy(x.b,hello); x.c = 21.50; printf(Union x : %d %s %f n,x.a,x.b,x.c); printf(Union y : %d %s %f n,y.a,y.b,y.c); } -- Shubham Maheshwari ShubZz O.o o.O enJoY ...!!! -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Shubham Maheshwari ShubZz O.o o.O enJoY ...!!! -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Regards, Kamakshi kamakshi...@gmail.com -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Shubham Maheshwari ShubZz O.o o.O enJoY ...!!! -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Regards, Kamakshi kamakshi...@gmail.com -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Shubham Maheshwari ShubZz O.o o.O enJoY ...!!! -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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
Re: [algogeeks] Re: Finding the Kth Prime
@Dave: could you please extrapolate on the 'sequence point rule' a bit more. i am nt familiar with it ... On Sun, Jul 17, 2011 at 3:01 AM, Dave dave_and_da...@juno.com wrote: @Anthony: Your code violates the sequence point rule, which states that the value of a variable can change at most one time between sequence points, and thus your code is nonstandard. The results of executing nonstandard code is undefined. Dave On Jul 15, 3:22 pm, Antony Kotre antonyko...@gmail.com wrote: sorry I don't know how to post new thread so posting my query here and please some one tell how to do that can any tell and explain the output of following code #includestdio.h main() { int a =5, b=5; int res1=(++a)+(++a)+(++a); int res2=(++b)+(++b)*10+(++b)*100; printf(%d\n%d\n,res1,res2); }- Hide quoted text - - Show quoted text - -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Shubham Maheshwari ShubZz O.o o.O enJoY ...!!! -- 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 http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Reverse a List with Recursion
Hi, I was trying to accomplish this task with the following call , header = ReverseList(header) I don't want to pass tail pointer or anything and just want that i get a reversed list with new header properly assigned after this call. I am getting issues in corner conditions like returning the correct node to be assigned to header. Can anyone give an elegant solution with above requirement? Since it is with recursion, please test for multiple scenarios (empty list, one node list, twe nodes list etc) before posting your solution. In case of empty list, the procedure should report that. -- Regards, Navneet -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Reverse a List with Recursion
int reverse(node * tmp) { static int i; // couti ; i++; if(tmp==NULL) { return 0; } if((tmp-next)==NULL) { head=tmp; i--; return 0; } if((tmp-next)!=NULL) { reverse(tmp-next); (tmp-next)-next=tmp; i--; if(i==0) { tmp-next=NULL; tail=tmp;} return 0; } return 0; } On Sun, Jul 17, 2011 at 2:42 PM, Navneet Gupta navneetn...@gmail.comwrote: Hi, I was trying to accomplish this task with the following call , header = ReverseList(header) I don't want to pass tail pointer or anything and just want that i get a reversed list with new header properly assigned after this call. I am getting issues in corner conditions like returning the correct node to be assigned to header. Can anyone give an elegant solution with above requirement? Since it is with recursion, please test for multiple scenarios (empty list, one node list, twe nodes list etc) before posting your solution. In case of empty list, the procedure should report that. -- Regards, Navneet -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Ankur Khurana Computer Science , 4th year Netaji Subhas Institute Of Technology Delhi. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Given a BST containing integers, and a value K. You have to find two nodes that give sum = K.
OK... suppose our tree is 5 /\ 4 6 / \ 3 7 / \ 2 8 / \ 1 9 now k=10; so will it return all the pairs like 1,9 2,8 . . ..5,5. . . .. .8,2 9,1 ?? On Sun, Jul 17, 2011 at 7:00 AM, saurabh singh saurab...@gmail.com wrote: @sagar This is what Dave is suggesting in a more pseudocode way:- 1-Traverse a pointer right down to the leftmost element,i.e.the shortest,say small 2-traverse a pointer left down to the rightmost element i.e.the largest.say large while(small!=large) 3-Compare their sum.If sumk set large to its successor in reverse inorder.(I am not sure if u meant the same but I am assuming rev inorder to be right-node-left) else set small to its inorder successor. break when u get the desired k. print :) return if u get out of the loop without getting the number then such number does not exist.print :( Amortized complexity order n. -- Saurabh Singh B.Tech (Computer Science) 5h sem MNNIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Reverse a List with Recursion
struct node *reverse_recurse(struct node *start) { if(start-next) { reverse_recurse(start-next); start-next-next=start; return(start); } else { head=start; } } in main if(head) { temp = reverse_recurse(head); temp-next =NULL; } head and temp are global On Sun, Jul 17, 2011 at 2:42 PM, Navneet Gupta navneetn...@gmail.comwrote: Hi, I was trying to accomplish this task with the following call , header = ReverseList(header) I don't want to pass tail pointer or anything and just want that i get a reversed list with new header properly assigned after this call. I am getting issues in corner conditions like returning the correct node to be assigned to header. Can anyone give an elegant solution with above requirement? Since it is with recursion, please test for multiple scenarios (empty list, one node list, twe nodes list etc) before posting your solution. In case of empty list, the procedure should report that. -- Regards, Navneet -- 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 http://groups.google.com/group/algogeeks?hl=en. -- best wishes!! Vaibhav Shukla DU-MCA -- 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 http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Free memory
Can we do this ? int i=12; free(i); Regards, Ankur Khurana Computer Science , 4th year Netaji Subhas Institute Of Technology Delhi. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Given a BST containing integers, and a value K. You have to find two nodes that give sum = K.
9 1 is analogous to 1 9...And the question requires only two nodes,it does not says about all such pairs. On Sun, Jul 17, 2011 at 2:52 PM, sagar pareek sagarpar...@gmail.com wrote: OK... suppose our tree is 5 /\ 4 6 / \ 3 7 / \ 2 8 / \ 1 9 now k=10; so will it return all the pairs like 1,9 2,8 . . ..5,5. . . .. .8,2 9,1 ?? On Sun, Jul 17, 2011 at 7:00 AM, saurabh singh saurab...@gmail.comwrote: @sagar This is what Dave is suggesting in a more pseudocode way:- 1-Traverse a pointer right down to the leftmost element,i.e.the shortest,say small 2-traverse a pointer left down to the rightmost element i.e.the largest.say large while(small!=large) 3-Compare their sum.If sumk set large to its successor in reverse inorder.(I am not sure if u meant the same but I am assuming rev inorder to be right-node-left) else set small to its inorder successor. break when u get the desired k. print :) return if u get out of the loop without getting the number then such number does not exist.print :( Amortized complexity order n. -- Saurabh Singh B.Tech (Computer Science) 5h sem MNNIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Free memory
more generally what is the memory structure of local , global and runtime allocated variable . I guess , runtime allocation is done from memory heap , local goes in to a stack . What about global ? On Sun, Jul 17, 2011 at 2:57 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote: Can we do this ? int i=12; free(i); Regards, Ankur Khurana Computer Science , 4th year Netaji Subhas Institute Of Technology Delhi. -- Ankur Khurana Computer Science , 4th year Netaji Subhas Institute Of Technology Delhi. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Free memory
Obviously you can't free the memory allocated in stack.The compiler won't call an error but once the code is executed it will cause run time error. On Sun, Jul 17, 2011 at 2:57 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote: Can we do this ? int i=12; free(i); Regards, Ankur Khurana Computer Science , 4th year Netaji Subhas Institute Of Technology Delhi. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Free memory
Global too goes to stack,the data stack.Static variables also go to the stack.That's how they retain their values during function calls. On Sun, Jul 17, 2011 at 3:02 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote: more generally what is the memory structure of local , global and runtime allocated variable . I guess , runtime allocation is done from memory heap , local goes in to a stack . What about global ? On Sun, Jul 17, 2011 at 2:57 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote: Can we do this ? int i=12; free(i); Regards, Ankur Khurana Computer Science , 4th year Netaji Subhas Institute Of Technology Delhi. -- Ankur Khurana Computer Science , 4th year Netaji Subhas Institute Of Technology Delhi. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Microsoft Interview Qn
This can be done like this 1. find out the height of the tree 2. make the number of arrays(node* pointers)=height of tree 3. traverse the tree from root as arr0[0]=root; arr1[0]=root-left; arr1[1]=root-right arr2[0]=arr1[0]-left arr2[1]=arr1[1]-right . . . and so on note:- if any arr[n]==NULL then make corresponding left and right entries NULL too now make the tree entries as :- arr[n]-right=arr[n+1] if arr[n] is last entry of tree make its right node NULL we are done :) On Sun, Jul 17, 2011 at 11:22 AM, naveen ms naveenms...@gmail.com wrote: in this recursive code...the right link node will point to its sibling to the right (if it has) or else it will be null. the left link of the node will point to its child(if it has) or else it will be null. regards, Naveen CSE R.V.C.E, Bangalore. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Free memory
local stack is different and global is different ? and runtime memory is going to memory heap that i know. Saurabh : above snippet does not give runtime error. On Sun, Jul 17, 2011 at 3:04 PM, saurabh singh saurab...@gmail.com wrote: Global too goes to stack,the data stack.Static variables also go to the stack.That's how they retain their values during function calls. On Sun, Jul 17, 2011 at 3:02 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote: more generally what is the memory structure of local , global and runtime allocated variable . I guess , runtime allocation is done from memory heap , local goes in to a stack . What about global ? On Sun, Jul 17, 2011 at 2:57 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote: Can we do this ? int i=12; free(i); Regards, Ankur Khurana Computer Science , 4th year Netaji Subhas Institute Of Technology Delhi. -- Ankur Khurana Computer Science , 4th year Netaji Subhas Institute Of Technology Delhi. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Ankur Khurana Computer Science , 4th year Netaji Subhas Institute Of Technology Delhi. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Reverse a List with Recursion
void rev_recursion(NODE **head) { if(*head==NULL) return; NODE *first, *rest; first=*head; rest=first-next; if(!rest) return; rev_recursion(rest); first-next-next=first; first-next=NULL; *head=rest; } On Sun, Jul 17, 2011 at 2:53 PM, vaibhav shukla vaibhav200...@gmail.comwrote: struct node *reverse_recurse(struct node *start) { if(start-next) { reverse_recurse(start-next); start-next-next=start; return(start); } else { head=start; } } in main if(head) { temp = reverse_recurse(head); temp-next =NULL; } head and temp are global On Sun, Jul 17, 2011 at 2:42 PM, Navneet Gupta navneetn...@gmail.comwrote: Hi, I was trying to accomplish this task with the following call , header = ReverseList(header) I don't want to pass tail pointer or anything and just want that i get a reversed list with new header properly assigned after this call. I am getting issues in corner conditions like returning the correct node to be assigned to header. Can anyone give an elegant solution with above requirement? Since it is with recursion, please test for multiple scenarios (empty list, one node list, twe nodes list etc) before posting your solution. In case of empty list, the procedure should report that. -- Regards, Navneet -- 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 http://groups.google.com/group/algogeeks?hl=en. -- best wishes!! Vaibhav Shukla DU-MCA -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Counting the ways.
i have an idea of changing each row to decimal equilant so we have an array of size n each array element has logn bits, resetting each all bits except one everytime and checking for AND of all n array it should take maximum of O(logn)^n. improvements or ideas are welcome surender On Sat, Jul 16, 2011 at 12:47 AM, Kunal Patil kp101...@gmail.com wrote: I agree with skript: Number of ways of doing this is n! One in the first row can be placed in n ways. After one in first row has been placed, we can place One in second row in n-1 ways and so on. So total num of ways is n*(n-1)*...*1 = n! One possible solution to this problem can be coded as follows: Input: integer n Output: different matrices satisfying given criteria Create an array of integers 1 to n. do { // Omega( n! ) For (i =0 to n-1) // Omega(n) print binary representation of (1 arr[i] ) upto n bits // Omega(n) } while( Next_Permutation( arr, arr+n ) ); TC: Omega ( n! ) * Omega ( n ) * omega ( n ) SC: O(n)...( I dunno [?] whether Next_permutation uses any extra space or what, so i am not considering it... [?] ) -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. 1B2.png324.png
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
@reynaled :- Happy to help @Sameer :- Thanks for pointing out and i think all you guyz now can optimize it :) On Sun, Jul 17, 2011 at 11:35 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: The question says Algo should be in place. So use of an array to print the right border of tree is not advisable. We can do it recursively without using an array also . On Sat, Jul 16, 2011 at 10:48 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed twice. otherwise it is fine. On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.comwrote: please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.comwrote: Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.comwrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.comwrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.comwrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Given a BST containing integers, and a value K. You have to find two nodes that give sum = K.
OK On Sun, Jul 17, 2011 at 2:59 PM, saurabh singh saurab...@gmail.com wrote: 9 1 is analogous to 1 9...And the question requires only two nodes,it does not says about all such pairs. On Sun, Jul 17, 2011 at 2:52 PM, sagar pareek sagarpar...@gmail.comwrote: OK... suppose our tree is 5 /\ 4 6 / \ 3 7 / \ 2 8 / \ 1 9 now k=10; so will it return all the pairs like 1,9 2,8 . . ..5,5. . . .. .8,2 9,1 ?? On Sun, Jul 17, 2011 at 7:00 AM, saurabh singh saurab...@gmail.comwrote: @sagar This is what Dave is suggesting in a more pseudocode way:- 1-Traverse a pointer right down to the leftmost element,i.e.the shortest,say small 2-traverse a pointer left down to the rightmost element i.e.the largest.say large while(small!=large) 3-Compare their sum.If sumk set large to its successor in reverse inorder.(I am not sure if u meant the same but I am assuming rev inorder to be right-node-left) else set small to its inorder successor. break when u get the desired k. print :) return if u get out of the loop without getting the number then such number does not exist.print :( Amortized complexity order n. -- Saurabh Singh B.Tech (Computer Science) 5h sem MNNIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
hey today ms visited our campus they asked simple 10 c output in first round and than 45 minutes coding round one question on test case on notepad,design bigint class,one simple question on array. On Sun, Jul 17, 2011 at 3:42 PM, sagar pareek sagarpar...@gmail.com wrote: @reynaled :- Happy to help @Sameer :- Thanks for pointing out and i think all you guyz now can optimize it :) On Sun, Jul 17, 2011 at 11:35 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: The question says Algo should be in place. So use of an array to print the right border of tree is not advisable. We can do it recursively without using an array also . On Sat, Jul 16, 2011 at 10:48 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed twice. otherwise it is fine. On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.comwrote: please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.comwrote: Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.com wrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.com wrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.comwrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- SOURABH
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
Yeah best of luck saurabh whaen results will be out? On Sun, Jul 17, 2011 at 3:47 PM, sourabh jakhar sourabhjak...@gmail.comwrote: hey today ms visited our campus they asked simple 10 c output in first round and than 45 minutes coding round one question on test case on notepad,design bigint class,one simple question on array. On Sun, Jul 17, 2011 at 3:42 PM, sagar pareek sagarpar...@gmail.comwrote: @reynaled :- Happy to help @Sameer :- Thanks for pointing out and i think all you guyz now can optimize it :) On Sun, Jul 17, 2011 at 11:35 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: The question says Algo should be in place. So use of an array to print the right border of tree is not advisable. We can do it recursively without using an array also . On Sat, Jul 16, 2011 at 10:48 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed twice. otherwise it is fine. On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.com wrote: please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.comwrote: Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.com wrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.com wrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.comwrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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
Re: [algogeeks] Re: Microsoft Interview Qn
This can be done using single array too... :) :) Do anybody wants the code? On Sun, Jul 17, 2011 at 3:04 PM, sagar pareek sagarpar...@gmail.com wrote: This can be done like this 1. find out the height of the tree 2. make the number of arrays(node* pointers)=height of tree 3. traverse the tree from root as arr0[0]=root; arr1[0]=root-left; arr1[1]=root-right arr2[0]=arr1[0]-left arr2[1]=arr1[1]-right . . . and so on note:- if any arr[n]==NULL then make corresponding left and right entries NULL too now make the tree entries as :- arr[n]-right=arr[n+1] if arr[n] is last entry of tree make its right node NULL we are done :) On Sun, Jul 17, 2011 at 11:22 AM, naveen ms naveenms...@gmail.com wrote: in this recursive code...the right link node will point to its sibling to the right (if it has) or else it will be null. the left link of the node will point to its child(if it has) or else it will be null. regards, Naveen CSE R.V.C.E, Bangalore. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Free memory
Machine/OS? I am pretty sure it will give. On Sun, Jul 17, 2011 at 3:09 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote: local stack is different and global is different ? and runtime memory is going to memory heap that i know. Saurabh : above snippet does not give runtime error. On Sun, Jul 17, 2011 at 3:04 PM, saurabh singh saurab...@gmail.comwrote: Global too goes to stack,the data stack.Static variables also go to the stack.That's how they retain their values during function calls. On Sun, Jul 17, 2011 at 3:02 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote: more generally what is the memory structure of local , global and runtime allocated variable . I guess , runtime allocation is done from memory heap , local goes in to a stack . What about global ? On Sun, Jul 17, 2011 at 2:57 PM, Ankur Khurana ankur.kkhur...@gmail.com wrote: Can we do this ? int i=12; free(i); Regards, Ankur Khurana Computer Science , 4th year Netaji Subhas Institute Of Technology Delhi. -- Ankur Khurana Computer Science , 4th year Netaji Subhas Institute Of Technology Delhi. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Ankur Khurana Computer Science , 4th year Netaji Subhas Institute Of Technology Delhi. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Free memory
yups it will give segmentation fault u should only free the memory allocated dynamically(heap) On Sun, Jul 17, 2011 at 3:59 PM, saurabh singh saurab...@gmail.com wrote: Machine/OS? I am pretty sure it will give. On Sun, Jul 17, 2011 at 3:09 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote: local stack is different and global is different ? and runtime memory is going to memory heap that i know. Saurabh : above snippet does not give runtime error. On Sun, Jul 17, 2011 at 3:04 PM, saurabh singh saurab...@gmail.comwrote: Global too goes to stack,the data stack.Static variables also go to the stack.That's how they retain their values during function calls. On Sun, Jul 17, 2011 at 3:02 PM, Ankur Khurana ankur.kkhur...@gmail.com wrote: more generally what is the memory structure of local , global and runtime allocated variable . I guess , runtime allocation is done from memory heap , local goes in to a stack . What about global ? On Sun, Jul 17, 2011 at 2:57 PM, Ankur Khurana ankur.kkhur...@gmail.com wrote: Can we do this ? int i=12; free(i); Regards, Ankur Khurana Computer Science , 4th year Netaji Subhas Institute Of Technology Delhi. -- Ankur Khurana Computer Science , 4th year Netaji Subhas Institute Of Technology Delhi. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Ankur Khurana Computer Science , 4th year Netaji Subhas Institute Of Technology Delhi. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- best wishes!! Vaibhav Shukla DU-MCA -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Free memory
http://www.ideone.com/LmFES On Sun, Jul 17, 2011 at 3:59 PM, saurabh singh saurab...@gmail.com wrote: Machine/OS? I am pretty sure it will give. On Sun, Jul 17, 2011 at 3:09 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote: local stack is different and global is different ? and runtime memory is going to memory heap that i know. Saurabh : above snippet does not give runtime error. On Sun, Jul 17, 2011 at 3:04 PM, saurabh singh saurab...@gmail.comwrote: Global too goes to stack,the data stack.Static variables also go to the stack.That's how they retain their values during function calls. On Sun, Jul 17, 2011 at 3:02 PM, Ankur Khurana ankur.kkhur...@gmail.com wrote: more generally what is the memory structure of local , global and runtime allocated variable . I guess , runtime allocation is done from memory heap , local goes in to a stack . What about global ? On Sun, Jul 17, 2011 at 2:57 PM, Ankur Khurana ankur.kkhur...@gmail.com wrote: Can we do this ? int i=12; free(i); Regards, Ankur Khurana Computer Science , 4th year Netaji Subhas Institute Of Technology Delhi. -- Ankur Khurana Computer Science , 4th year Netaji Subhas Institute Of Technology Delhi. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Ankur Khurana Computer Science , 4th year Netaji Subhas Institute Of Technology Delhi. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] MICROSOFT
given an array a[0..n-1] .required to find the output array out [0.n-1] such that out [i] is the product of all the numbers a[0] to a[n-1] excluding a[i] for ex out[2]=a[0]*a[1]*a[3]*a[4]a[n-1] constraint is not using division operator how to do this in O(n)?? -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Reverse a List with Recursion
node *listing::rev(node *p) { if(p-next==NULL) { head=p; return p; } else { node *t=rev(p-next); t-next=p; p-next=NULL; tail=p; return p; } } On Sun, Jul 17, 2011 at 3:21 PM, Nishant Mittal mittal.nishan...@gmail.comwrote: void rev_recursion(NODE **head) { if(*head==NULL) return; NODE *first, *rest; first=*head; rest=first-next; if(!rest) return; rev_recursion(rest); first-next-next=first; first-next=NULL; *head=rest; } On Sun, Jul 17, 2011 at 2:53 PM, vaibhav shukla vaibhav200...@gmail.comwrote: struct node *reverse_recurse(struct node *start) { if(start-next) { reverse_recurse(start-next); start-next-next=start; return(start); } else { head=start; } } in main if(head) { temp = reverse_recurse(head); temp-next =NULL; } head and temp are global On Sun, Jul 17, 2011 at 2:42 PM, Navneet Gupta navneetn...@gmail.comwrote: Hi, I was trying to accomplish this task with the following call , header = ReverseList(header) I don't want to pass tail pointer or anything and just want that i get a reversed list with new header properly assigned after this call. I am getting issues in corner conditions like returning the correct node to be assigned to header. Can anyone give an elegant solution with above requirement? Since it is with recursion, please test for multiple scenarios (empty list, one node list, twe nodes list etc) before posting your solution. In case of empty list, the procedure should report that. -- Regards, Navneet -- 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 http://groups.google.com/group/algogeeks?hl=en. -- best wishes!! Vaibhav Shukla DU-MCA -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Reverse a List with Recursion
initial call to this will be rev(head); On Sun, Jul 17, 2011 at 4:28 PM, Anika Jain anika.jai...@gmail.com wrote: node *listing::rev(node *p) { if(p-next==NULL) { head=p; return p; } else { node *t=rev(p-next); t-next=p; p-next=NULL; tail=p; return p; } } On Sun, Jul 17, 2011 at 3:21 PM, Nishant Mittal mittal.nishan...@gmail.com wrote: void rev_recursion(NODE **head) { if(*head==NULL) return; NODE *first, *rest; first=*head; rest=first-next; if(!rest) return; rev_recursion(rest); first-next-next=first; first-next=NULL; *head=rest; } On Sun, Jul 17, 2011 at 2:53 PM, vaibhav shukla vaibhav200...@gmail.comwrote: struct node *reverse_recurse(struct node *start) { if(start-next) { reverse_recurse(start-next); start-next-next=start; return(start); } else { head=start; } } in main if(head) { temp = reverse_recurse(head); temp-next =NULL; } head and temp are global On Sun, Jul 17, 2011 at 2:42 PM, Navneet Gupta navneetn...@gmail.comwrote: Hi, I was trying to accomplish this task with the following call , header = ReverseList(header) I don't want to pass tail pointer or anything and just want that i get a reversed list with new header properly assigned after this call. I am getting issues in corner conditions like returning the correct node to be assigned to header. Can anyone give an elegant solution with above requirement? Since it is with recursion, please test for multiple scenarios (empty list, one node list, twe nodes list etc) before posting your solution. In case of empty list, the procedure should report that. -- Regards, Navneet -- 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 http://groups.google.com/group/algogeeks?hl=en. -- best wishes!! Vaibhav Shukla DU-MCA -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] MICROSOFT
take 2 arrays before and after... before[i] contains the product of all the numbers before i and after[i] contains product of all the numbers after i something like this before[0]=1; after[n-1]=1; for(i=1;in;i++) { before[i]=a[i-1]*before[i-1]; after[n-i-1]=after[n-i]*a[n-i]; } for(i=0;in;i++) printf(%d\n,before[i]*after[i]); On Sun, Jul 17, 2011 at 4:28 PM, geek forgeek geekhori...@gmail.com wrote: given an array a[0..n-1] .required to find the output array out [0.n-1] such that out [i] is the product of all the numbers a[0] to a[n-1] excluding a[i] for ex out[2]=a[0]*a[1]*a[3]*a[4]a[n-1] constraint is not using division operator how to do this in O(n)?? -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
@sourabh jakhar: how to design that big int class?? what data structure to use?? On Sun, Jul 17, 2011 at 3:55 PM, sourabh jakhar sourabhjak...@gmail.comwrote: i donot know abt the results but one thing for sure get your basic first right and than do the weird question On Sun, Jul 17, 2011 at 3:53 PM, sagar pareek sagarpar...@gmail.comwrote: Yeah best of luck saurabh whaen results will be out? On Sun, Jul 17, 2011 at 3:47 PM, sourabh jakhar sourabhjak...@gmail.comwrote: hey today ms visited our campus they asked simple 10 c output in first round and than 45 minutes coding round one question on test case on notepad,design bigint class,one simple question on array. On Sun, Jul 17, 2011 at 3:42 PM, sagar pareek sagarpar...@gmail.comwrote: @reynaled :- Happy to help @Sameer :- Thanks for pointing out and i think all you guyz now can optimize it :) On Sun, Jul 17, 2011 at 11:35 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: The question says Algo should be in place. So use of an array to print the right border of tree is not advisable. We can do it recursively without using an array also . On Sat, Jul 16, 2011 at 10:48 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed twice. otherwise it is fine. On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.com wrote: please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.com wrote: Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.com wrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.com wrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.com wrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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
Re: [algogeeks] MICROSOFT
take two extra arrays b[] and c[] in b[] store the following thing b[0]=1; b[i]=b[i-1]*a[i-1]; in c[] store following things c[n-1]=1; c[i]=c[i+1]*a[i+1] (in-1) fill the c[] array in reverse order i.e. start from n-1 then go to 0; now output[] would be output[i]=b[i]*c[i]; On Sun, Jul 17, 2011 at 4:28 PM, geek forgeek geekhori...@gmail.com wrote: given an array a[0..n-1] .required to find the output array out [0.n-1] such that out [i] is the product of all the numbers a[0] to a[n-1] excluding a[i] for ex out[2]=a[0]*a[1]*a[3]*a[4]a[n-1] constraint is not using division operator how to do this in O(n)?? -- 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 http://groups.google.com/group/algogeeks?hl=en. Anurag Aggarwal -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] MICROSOFT
ohh its pretty easy i cudnt make it in the written.. nywayz thanx @nishant and @anurag On Sun, Jul 17, 2011 at 4:35 PM, Anurag Aggarwal anurag19aggar...@gmail.com wrote: take two extra arrays b[] and c[] in b[] store the following thing b[0]=1; b[i]=b[i-1]*a[i-1]; in c[] store following things c[n-1]=1; c[i]=c[i+1]*a[i+1] (in-1) fill the c[] array in reverse order i.e. start from n-1 then go to 0; now output[] would be output[i]=b[i]*c[i]; On Sun, Jul 17, 2011 at 4:28 PM, geek forgeek geekhori...@gmail.comwrote: given an array a[0..n-1] .required to find the output array out [0.n-1] such that out [i] is the product of all the numbers a[0] to a[n-1] excluding a[i] for ex out[2]=a[0]*a[1]*a[3]*a[4]a[n-1] constraint is not using division operator how to do this in O(n)?? -- 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 http://groups.google.com/group/algogeeks?hl=en. Anurag Aggarwal -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] MICROSOFT
thanx the question was asked by MS today in MNNIT. On Sun, Jul 17, 2011 at 4:35 PM, Anurag Aggarwal anurag19aggar...@gmail.com wrote: take two extra arrays b[] and c[] in b[] store the following thing b[0]=1; b[i]=b[i-1]*a[i-1]; in c[] store following things c[n-1]=1; c[i]=c[i+1]*a[i+1] (in-1) fill the c[] array in reverse order i.e. start from n-1 then go to 0; now output[] would be output[i]=b[i]*c[i]; On Sun, Jul 17, 2011 at 4:28 PM, geek forgeek geekhori...@gmail.comwrote: given an array a[0..n-1] .required to find the output array out [0.n-1] such that out [i] is the product of all the numbers a[0] to a[n-1] excluding a[i] for ex out[2]=a[0]*a[1]*a[3]*a[4]a[n-1] constraint is not using division operator how to do this in O(n)?? -- 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 http://groups.google.com/group/algogeeks?hl=en. Anurag Aggarwal -- 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 http://groups.google.com/group/algogeeks?hl=en. -- With Regards Manish Patel BTech 2nd Year Computer Science And Engineering National Institute of Technology -Allahabad -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] MICROSOFT
It can be done using one extra array only that is the output array out[] *int out = (int *)malloc(sizeof(n)); //n is the number of elements in a int i,temp = 1; for(i=0;in;i++) { out[i] = temp; temp*=a[i]; } temp =1; for(i=n-1;i=0;i--) { out[i] *= temp; temp*=a[i]; }* On Sun, Jul 17, 2011 at 4:43 PM, manish patel manispatel...@gmail.comwrote: thanx the question was asked by MS today in MNNIT. On Sun, Jul 17, 2011 at 4:35 PM, Anurag Aggarwal anurag19aggar...@gmail.com wrote: take two extra arrays b[] and c[] in b[] store the following thing b[0]=1; b[i]=b[i-1]*a[i-1]; in c[] store following things c[n-1]=1; c[i]=c[i+1]*a[i+1] (in-1) fill the c[] array in reverse order i.e. start from n-1 then go to 0; now output[] would be output[i]=b[i]*c[i]; On Sun, Jul 17, 2011 at 4:28 PM, geek forgeek geekhori...@gmail.comwrote: given an array a[0..n-1] .required to find the output array out [0.n-1] such that out [i] is the product of all the numbers a[0] to a[n-1] excluding a[i] for ex out[2]=a[0]*a[1]*a[3]*a[4]a[n-1] constraint is not using division operator how to do this in O(n)?? -- 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 http://groups.google.com/group/algogeeks?hl=en. Anurag Aggarwal -- 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 http://groups.google.com/group/algogeeks?hl=en. -- With Regards Manish Patel BTech 2nd Year Computer Science And Engineering National Institute of Technology -Allahabad -- 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 http://groups.google.com/group/algogeeks?hl=en. -- *Piyush Sinha* *IIIT, Allahabad* *+91-7483122727* * https://www.facebook.com/profile.php?id=10655377926 NEVER SAY NEVER * -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Free memory
holy sh*t . I need to switch from MinGw was using codeblocks. Thanks :) On Sun, Jul 17, 2011 at 4:02 PM, saurabh singh saurab...@gmail.com wrote: http://www.ideone.com/LmFES On Sun, Jul 17, 2011 at 3:59 PM, saurabh singh saurab...@gmail.comwrote: Machine/OS? I am pretty sure it will give. On Sun, Jul 17, 2011 at 3:09 PM, Ankur Khurana ankur.kkhur...@gmail.comwrote: local stack is different and global is different ? and runtime memory is going to memory heap that i know. Saurabh : above snippet does not give runtime error. On Sun, Jul 17, 2011 at 3:04 PM, saurabh singh saurab...@gmail.comwrote: Global too goes to stack,the data stack.Static variables also go to the stack.That's how they retain their values during function calls. On Sun, Jul 17, 2011 at 3:02 PM, Ankur Khurana ankur.kkhur...@gmail.com wrote: more generally what is the memory structure of local , global and runtime allocated variable . I guess , runtime allocation is done from memory heap , local goes in to a stack . What about global ? On Sun, Jul 17, 2011 at 2:57 PM, Ankur Khurana ankur.kkhur...@gmail.com wrote: Can we do this ? int i=12; free(i); Regards, Ankur Khurana Computer Science , 4th year Netaji Subhas Institute Of Technology Delhi. -- Ankur Khurana Computer Science , 4th year Netaji Subhas Institute Of Technology Delhi. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Ankur Khurana Computer Science , 4th year Netaji Subhas Institute Of Technology Delhi. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Ankur Khurana Computer Science , 4th year Netaji Subhas Institute Of Technology Delhi. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Reverse a List with Recursion
node * reverse(node *head) { if(head-next) { node * temp=reverse(head-next); head-next-next=head; head-next=NULL; return temp; } return head; } On Sun, Jul 17, 2011 at 4:57 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: *node *reverse(node *head) { if(head==NULL) return head; if(head-next==NULL) return head; node *temp = reverse(head-next); head-next-next = head; head-next = NULL; return (temp); }* On Sun, Jul 17, 2011 at 4:30 PM, Anika Jain anika.jai...@gmail.comwrote: initial call to this will be rev(head); On Sun, Jul 17, 2011 at 4:28 PM, Anika Jain anika.jai...@gmail.comwrote: node *listing::rev(node *p) { if(p-next==NULL) { head=p; return p; } else { node *t=rev(p-next); t-next=p; p-next=NULL; tail=p; return p; } } On Sun, Jul 17, 2011 at 3:21 PM, Nishant Mittal mittal.nishan...@gmail.com wrote: void rev_recursion(NODE **head) { if(*head==NULL) return; NODE *first, *rest; first=*head; rest=first-next; if(!rest) return; rev_recursion(rest); first-next-next=first; first-next=NULL; *head=rest; } On Sun, Jul 17, 2011 at 2:53 PM, vaibhav shukla vaibhav200...@gmail.com wrote: struct node *reverse_recurse(struct node *start) { if(start-next) { reverse_recurse(start-next); start-next-next=start; return(start); } else { head=start; } } in main if(head) { temp = reverse_recurse(head); temp-next =NULL; } head and temp are global On Sun, Jul 17, 2011 at 2:42 PM, Navneet Gupta navneetn...@gmail.comwrote: Hi, I was trying to accomplish this task with the following call , header = ReverseList(header) I don't want to pass tail pointer or anything and just want that i get a reversed list with new header properly assigned after this call. I am getting issues in corner conditions like returning the correct node to be assigned to header. Can anyone give an elegant solution with above requirement? Since it is with recursion, please test for multiple scenarios (empty list, one node list, twe nodes list etc) before posting your solution. In case of empty list, the procedure should report that. -- Regards, Navneet -- 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 http://groups.google.com/group/algogeeks?hl=en. -- best wishes!! Vaibhav Shukla DU-MCA -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- *Piyush Sinha* *IIIT, Allahabad* *+91-7483122727* * https://www.facebook.com/profile.php?id=10655377926 NEVER SAY NEVER * -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] MICROSOFT
@manish, can you please tell other questions asked by ms today? On Sun, Jul 17, 2011 at 4:53 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: It can be done using one extra array only that is the output array out[] *int out = (int *)malloc(sizeof(n)); //n is the number of elements in a int i,temp = 1; for(i=0;in;i++) { out[i] = temp; temp*=a[i]; } temp =1; for(i=n-1;i=0;i--) { out[i] *= temp; temp*=a[i]; }* On Sun, Jul 17, 2011 at 4:43 PM, manish patel manispatel...@gmail.comwrote: thanx the question was asked by MS today in MNNIT. On Sun, Jul 17, 2011 at 4:35 PM, Anurag Aggarwal anurag19aggar...@gmail.com wrote: take two extra arrays b[] and c[] in b[] store the following thing b[0]=1; b[i]=b[i-1]*a[i-1]; in c[] store following things c[n-1]=1; c[i]=c[i+1]*a[i+1] (in-1) fill the c[] array in reverse order i.e. start from n-1 then go to 0; now output[] would be output[i]=b[i]*c[i]; On Sun, Jul 17, 2011 at 4:28 PM, geek forgeek geekhori...@gmail.comwrote: given an array a[0..n-1] .required to find the output array out [0.n-1] such that out [i] is the product of all the numbers a[0] to a[n-1] excluding a[i] for ex out[2]=a[0]*a[1]*a[3]*a[4]a[n-1] constraint is not using division operator how to do this in O(n)?? -- 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 http://groups.google.com/group/algogeeks?hl=en. Anurag Aggarwal -- 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 http://groups.google.com/group/algogeeks?hl=en. -- With Regards Manish Patel BTech 2nd Year Computer Science And Engineering National Institute of Technology -Allahabad -- 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 http://groups.google.com/group/algogeeks?hl=en. -- *Piyush Sinha* *IIIT, Allahabad* *+91-7483122727* * https://www.facebook.com/profile.php?id=10655377926 NEVER SAY NEVER * -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Best Regards, Harshal Choudhary 7th Semester, CSE Dept. NIT Surathkal, India. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] MICROSOFT
10 c output question . questions were moderate type but negative marking +3 and -2.(30 min) coding round.(45 min) 1.array simple question d.p 2.test cases of notepad 3.Design Big Int class in C or c++ On Sun, Jul 17, 2011 at 5:14 PM, Harshal hc4...@gmail.com wrote: @manish, can you please tell other questions asked by ms today? On Sun, Jul 17, 2011 at 4:53 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: It can be done using one extra array only that is the output array out[] *int out = (int *)malloc(sizeof(n)); //n is the number of elements in a int i,temp = 1; for(i=0;in;i++) { out[i] = temp; temp*=a[i]; } temp =1; for(i=n-1;i=0;i--) { out[i] *= temp; temp*=a[i]; }* On Sun, Jul 17, 2011 at 4:43 PM, manish patel manispatel...@gmail.comwrote: thanx the question was asked by MS today in MNNIT. On Sun, Jul 17, 2011 at 4:35 PM, Anurag Aggarwal anurag19aggar...@gmail.com wrote: take two extra arrays b[] and c[] in b[] store the following thing b[0]=1; b[i]=b[i-1]*a[i-1]; in c[] store following things c[n-1]=1; c[i]=c[i+1]*a[i+1] (in-1) fill the c[] array in reverse order i.e. start from n-1 then go to 0; now output[] would be output[i]=b[i]*c[i]; On Sun, Jul 17, 2011 at 4:28 PM, geek forgeek geekhori...@gmail.comwrote: given an array a[0..n-1] .required to find the output array out [0.n-1] such that out [i] is the product of all the numbers a[0] to a[n-1] excluding a[i] for ex out[2]=a[0]*a[1]*a[3]*a[4]a[n-1] constraint is not using division operator how to do this in O(n)?? -- 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 http://groups.google.com/group/algogeeks?hl=en. Anurag Aggarwal -- 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 http://groups.google.com/group/algogeeks?hl=en. -- With Regards Manish Patel BTech 2nd Year Computer Science And Engineering National Institute of Technology -Allahabad -- 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 http://groups.google.com/group/algogeeks?hl=en. -- *Piyush Sinha* *IIIT, Allahabad* *+91-7483122727* * https://www.facebook.com/profile.php?id=10655377926 NEVER SAY NEVER * -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Best Regards, Harshal Choudhary 7th Semester, CSE Dept. NIT Surathkal, India. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- SOURABH JAKHAR,(CSE)(3 year) ROOM NO 167 , TILAK,HOSTEL 'MNNIT ALLAHABAD The Law of Win says, Let's not do it your way or my way; let's do it the best way. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] MICROSOFT
Use linked list for designing big int class On Sun, Jul 17, 2011 at 5:17 PM, sourabh jakhar sourabhjak...@gmail.comwrote: 10 c output question . questions were moderate type but negative marking +3 and -2.(30 min) coding round.(45 min) 1.array simple question d.p 2.test cases of notepad 3.Design Big Int class in C or c++ On Sun, Jul 17, 2011 at 5:14 PM, Harshal hc4...@gmail.com wrote: @manish, can you please tell other questions asked by ms today? On Sun, Jul 17, 2011 at 4:53 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: It can be done using one extra array only that is the output array out[] *int out = (int *)malloc(sizeof(n)); //n is the number of elements in a int i,temp = 1; for(i=0;in;i++) { out[i] = temp; temp*=a[i]; } temp =1; for(i=n-1;i=0;i--) { out[i] *= temp; temp*=a[i]; }* On Sun, Jul 17, 2011 at 4:43 PM, manish patel manispatel...@gmail.comwrote: thanx the question was asked by MS today in MNNIT. On Sun, Jul 17, 2011 at 4:35 PM, Anurag Aggarwal anurag19aggar...@gmail.com wrote: take two extra arrays b[] and c[] in b[] store the following thing b[0]=1; b[i]=b[i-1]*a[i-1]; in c[] store following things c[n-1]=1; c[i]=c[i+1]*a[i+1] (in-1) fill the c[] array in reverse order i.e. start from n-1 then go to 0; now output[] would be output[i]=b[i]*c[i]; On Sun, Jul 17, 2011 at 4:28 PM, geek forgeek geekhori...@gmail.comwrote: given an array a[0..n-1] .required to find the output array out [0.n-1] such that out [i] is the product of all the numbers a[0] to a[n-1] excluding a[i] for ex out[2]=a[0]*a[1]*a[3]*a[4]a[n-1] constraint is not using division operator how to do this in O(n)?? -- 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 http://groups.google.com/group/algogeeks?hl=en. Anurag Aggarwal -- 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 http://groups.google.com/group/algogeeks?hl=en. -- With Regards Manish Patel BTech 2nd Year Computer Science And Engineering National Institute of Technology -Allahabad -- 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 http://groups.google.com/group/algogeeks?hl=en. -- *Piyush Sinha* *IIIT, Allahabad* *+91-7483122727* * https://www.facebook.com/profile.php?id=10655377926 NEVER SAY NEVER * -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Best Regards, Harshal Choudhary 7th Semester, CSE Dept. NIT Surathkal, India. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- SOURABH JAKHAR,(CSE)(3 year) ROOM NO 167 , TILAK,HOSTEL 'MNNIT ALLAHABAD The Law of Win says, Let's not do it your way or my way; let's do it the best way. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- *Piyush Sinha* *IIIT, Allahabad* *+91-7483122727* * https://www.facebook.com/profile.php?id=10655377926 NEVER SAY NEVER * -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] MICROSOFT
thanks sourabh :) On Sun, Jul 17, 2011 at 5:17 PM, sourabh jakhar sourabhjak...@gmail.comwrote: 10 c output question . questions were moderate type but negative marking +3 and -2.(30 min) coding round.(45 min) 1.array simple question d.p 2.test cases of notepad 3.Design Big Int class in C or c++ On Sun, Jul 17, 2011 at 5:14 PM, Harshal hc4...@gmail.com wrote: @manish, can you please tell other questions asked by ms today? On Sun, Jul 17, 2011 at 4:53 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: It can be done using one extra array only that is the output array out[] *int out = (int *)malloc(sizeof(n)); //n is the number of elements in a int i,temp = 1; for(i=0;in;i++) { out[i] = temp; temp*=a[i]; } temp =1; for(i=n-1;i=0;i--) { out[i] *= temp; temp*=a[i]; }* On Sun, Jul 17, 2011 at 4:43 PM, manish patel manispatel...@gmail.comwrote: thanx the question was asked by MS today in MNNIT. On Sun, Jul 17, 2011 at 4:35 PM, Anurag Aggarwal anurag19aggar...@gmail.com wrote: take two extra arrays b[] and c[] in b[] store the following thing b[0]=1; b[i]=b[i-1]*a[i-1]; in c[] store following things c[n-1]=1; c[i]=c[i+1]*a[i+1] (in-1) fill the c[] array in reverse order i.e. start from n-1 then go to 0; now output[] would be output[i]=b[i]*c[i]; On Sun, Jul 17, 2011 at 4:28 PM, geek forgeek geekhori...@gmail.comwrote: given an array a[0..n-1] .required to find the output array out [0.n-1] such that out [i] is the product of all the numbers a[0] to a[n-1] excluding a[i] for ex out[2]=a[0]*a[1]*a[3]*a[4]a[n-1] constraint is not using division operator how to do this in O(n)?? -- 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 http://groups.google.com/group/algogeeks?hl=en. Anurag Aggarwal -- 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 http://groups.google.com/group/algogeeks?hl=en. -- With Regards Manish Patel BTech 2nd Year Computer Science And Engineering National Institute of Technology -Allahabad -- 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 http://groups.google.com/group/algogeeks?hl=en. -- *Piyush Sinha* *IIIT, Allahabad* *+91-7483122727* * https://www.facebook.com/profile.php?id=10655377926 NEVER SAY NEVER * -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Best Regards, Harshal Choudhary 7th Semester, CSE Dept. NIT Surathkal, India. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- SOURABH JAKHAR,(CSE)(3 year) ROOM NO 167 , TILAK,HOSTEL 'MNNIT ALLAHABAD The Law of Win says, Let's not do it your way or my way; let's do it the best way. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Best Regards, Harshal Choudhary 7th Semester, CSE Dept. NIT Surathkal, India. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] MICROSOFT
we can also use dynamically allocated array where they contain the digits of number and than apply the operation it is a better option i think as we can go to any index in 0(1) time. On Sun, Jul 17, 2011 at 5:19 PM, Harshal hc4...@gmail.com wrote: thanks sourabh :) On Sun, Jul 17, 2011 at 5:17 PM, sourabh jakhar sourabhjak...@gmail.comwrote: 10 c output question . questions were moderate type but negative marking +3 and -2.(30 min) coding round.(45 min) 1.array simple question d.p 2.test cases of notepad 3.Design Big Int class in C or c++ On Sun, Jul 17, 2011 at 5:14 PM, Harshal hc4...@gmail.com wrote: @manish, can you please tell other questions asked by ms today? On Sun, Jul 17, 2011 at 4:53 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: It can be done using one extra array only that is the output array out[] *int out = (int *)malloc(sizeof(n)); //n is the number of elements in a int i,temp = 1; for(i=0;in;i++) { out[i] = temp; temp*=a[i]; } temp =1; for(i=n-1;i=0;i--) { out[i] *= temp; temp*=a[i]; }* On Sun, Jul 17, 2011 at 4:43 PM, manish patel manispatel...@gmail.comwrote: thanx the question was asked by MS today in MNNIT. On Sun, Jul 17, 2011 at 4:35 PM, Anurag Aggarwal anurag19aggar...@gmail.com wrote: take two extra arrays b[] and c[] in b[] store the following thing b[0]=1; b[i]=b[i-1]*a[i-1]; in c[] store following things c[n-1]=1; c[i]=c[i+1]*a[i+1] (in-1) fill the c[] array in reverse order i.e. start from n-1 then go to 0; now output[] would be output[i]=b[i]*c[i]; On Sun, Jul 17, 2011 at 4:28 PM, geek forgeek geekhori...@gmail.comwrote: given an array a[0..n-1] .required to find the output array out [0.n-1] such that out [i] is the product of all the numbers a[0] to a[n-1] excluding a[i] for ex out[2]=a[0]*a[1]*a[3]*a[4]a[n-1] constraint is not using division operator how to do this in O(n)?? -- 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 http://groups.google.com/group/algogeeks?hl=en. Anurag Aggarwal -- 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 http://groups.google.com/group/algogeeks?hl=en. -- With Regards Manish Patel BTech 2nd Year Computer Science And Engineering National Institute of Technology -Allahabad -- 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 http://groups.google.com/group/algogeeks?hl=en. -- *Piyush Sinha* *IIIT, Allahabad* *+91-7483122727* * https://www.facebook.com/profile.php?id=10655377926 NEVER SAY NEVER * -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Best Regards, Harshal Choudhary 7th Semester, CSE Dept. NIT Surathkal, India. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- SOURABH JAKHAR,(CSE)(3 year) ROOM NO 167 , TILAK,HOSTEL 'MNNIT ALLAHABAD The Law of Win says, Let's not do it your way or my way; let's do it the best way. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Best Regards, Harshal Choudhary 7th Semester, CSE Dept. NIT Surathkal, India. -- 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
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
@saurabh Ok... on 20th amazon is coming :) On Sun, Jul 17, 2011 at 4:35 PM, prasanth n nprasnt...@gmail.com wrote: @sourabh jakhar: how to design that big int class?? what data structure to use?? On Sun, Jul 17, 2011 at 3:55 PM, sourabh jakhar sourabhjak...@gmail.comwrote: i donot know abt the results but one thing for sure get your basic first right and than do the weird question On Sun, Jul 17, 2011 at 3:53 PM, sagar pareek sagarpar...@gmail.comwrote: Yeah best of luck saurabh whaen results will be out? On Sun, Jul 17, 2011 at 3:47 PM, sourabh jakhar sourabhjak...@gmail.com wrote: hey today ms visited our campus they asked simple 10 c output in first round and than 45 minutes coding round one question on test case on notepad,design bigint class,one simple question on array. On Sun, Jul 17, 2011 at 3:42 PM, sagar pareek sagarpar...@gmail.comwrote: @reynaled :- Happy to help @Sameer :- Thanks for pointing out and i think all you guyz now can optimize it :) On Sun, Jul 17, 2011 at 11:35 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: The question says Algo should be in place. So use of an array to print the right border of tree is not advisable. We can do it recursively without using an array also . On Sat, Jul 16, 2011 at 10:48 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed twice. otherwise it is fine. On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.com wrote: please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.com wrote: Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.com wrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.com wrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.com wrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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.
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
@prasanth Trie will be used... :) :) On Sun, Jul 17, 2011 at 5:28 PM, sagar pareek sagarpar...@gmail.com wrote: @saurabh Ok... on 20th amazon is coming :) On Sun, Jul 17, 2011 at 4:35 PM, prasanth n nprasnt...@gmail.com wrote: @sourabh jakhar: how to design that big int class?? what data structure to use?? On Sun, Jul 17, 2011 at 3:55 PM, sourabh jakhar sourabhjak...@gmail.comwrote: i donot know abt the results but one thing for sure get your basic first right and than do the weird question On Sun, Jul 17, 2011 at 3:53 PM, sagar pareek sagarpar...@gmail.comwrote: Yeah best of luck saurabh whaen results will be out? On Sun, Jul 17, 2011 at 3:47 PM, sourabh jakhar sourabhjak...@gmail.com wrote: hey today ms visited our campus they asked simple 10 c output in first round and than 45 minutes coding round one question on test case on notepad,design bigint class,one simple question on array. On Sun, Jul 17, 2011 at 3:42 PM, sagar pareek sagarpar...@gmail.comwrote: @reynaled :- Happy to help @Sameer :- Thanks for pointing out and i think all you guyz now can optimize it :) On Sun, Jul 17, 2011 at 11:35 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: The question says Algo should be in place. So use of an array to print the right border of tree is not advisable. We can do it recursively without using an array also . On Sat, Jul 16, 2011 at 10:48 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed twice. otherwise it is fine. On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.com wrote: please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.com wrote: Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.com wrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.com wrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.com wrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you
Re: [algogeeks] MICROSOFT
@Saurabh...ya true buddy...using malloc and realloc functions...gr88 On Sun, Jul 17, 2011 at 5:24 PM, sourabh jakhar sourabhjak...@gmail.comwrote: we can also use dynamically allocated array where they contain the digits of number and than apply the operation it is a better option i think as we can go to any index in 0(1) time. On Sun, Jul 17, 2011 at 5:19 PM, Harshal hc4...@gmail.com wrote: thanks sourabh :) On Sun, Jul 17, 2011 at 5:17 PM, sourabh jakhar sourabhjak...@gmail.comwrote: 10 c output question . questions were moderate type but negative marking +3 and -2.(30 min) coding round.(45 min) 1.array simple question d.p 2.test cases of notepad 3.Design Big Int class in C or c++ On Sun, Jul 17, 2011 at 5:14 PM, Harshal hc4...@gmail.com wrote: @manish, can you please tell other questions asked by ms today? On Sun, Jul 17, 2011 at 4:53 PM, Piyush Sinha ecstasy.piy...@gmail.com wrote: It can be done using one extra array only that is the output array out[] *int out = (int *)malloc(sizeof(n)); //n is the number of elements in a int i,temp = 1; for(i=0;in;i++) { out[i] = temp; temp*=a[i]; } temp =1; for(i=n-1;i=0;i--) { out[i] *= temp; temp*=a[i]; }* On Sun, Jul 17, 2011 at 4:43 PM, manish patel manispatel...@gmail.com wrote: thanx the question was asked by MS today in MNNIT. On Sun, Jul 17, 2011 at 4:35 PM, Anurag Aggarwal anurag19aggar...@gmail.com wrote: take two extra arrays b[] and c[] in b[] store the following thing b[0]=1; b[i]=b[i-1]*a[i-1]; in c[] store following things c[n-1]=1; c[i]=c[i+1]*a[i+1] (in-1) fill the c[] array in reverse order i.e. start from n-1 then go to 0; now output[] would be output[i]=b[i]*c[i]; On Sun, Jul 17, 2011 at 4:28 PM, geek forgeek geekhori...@gmail.com wrote: given an array a[0..n-1] .required to find the output array out [0.n-1] such that out [i] is the product of all the numbers a[0] to a[n-1] excluding a[i] for ex out[2]=a[0]*a[1]*a[3]*a[4]a[n-1] constraint is not using division operator how to do this in O(n)?? -- 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 http://groups.google.com/group/algogeeks?hl=en. Anurag Aggarwal -- 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 http://groups.google.com/group/algogeeks?hl=en. -- With Regards Manish Patel BTech 2nd Year Computer Science And Engineering National Institute of Technology -Allahabad -- 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 http://groups.google.com/group/algogeeks?hl=en. -- *Piyush Sinha* *IIIT, Allahabad* *+91-7483122727* * https://www.facebook.com/profile.php?id=10655377926 NEVER SAY NEVER * -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Best Regards, Harshal Choudhary 7th Semester, CSE Dept. NIT Surathkal, India. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- SOURABH JAKHAR,(CSE)(3 year) ROOM NO 167 , TILAK,HOSTEL 'MNNIT ALLAHABAD The Law of Win says, Let's not do it your way or my way; let's do it the best way. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Best Regards, Harshal Choudhary 7th Semester, CSE Dept. NIT Surathkal, India. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,
[algogeeks] Re: Finding the Kth Prime
@Shubham: Google is your friend. Dave On Jul 17, 3:22 am, Shubham Maheshwari shubham.veloc...@gmail.com wrote: @Dave: could you please extrapolate on the 'sequence point rule' a bit more. i am nt familiar with it ... On Sun, Jul 17, 2011 at 3:01 AM, Dave dave_and_da...@juno.com wrote: @Anthony: Your code violates the sequence point rule, which states that the value of a variable can change at most one time between sequence points, and thus your code is nonstandard. The results of executing nonstandard code is undefined. Dave On Jul 15, 3:22 pm, Antony Kotre antonyko...@gmail.com wrote: sorry I don't know how to post new thread so posting my query here and please some one tell how to do that can any tell and explain the output of following code #includestdio.h main() { int a =5, b=5; int res1=(++a)+(++a)+(++a); int res2=(++b)+(++b)*10+(++b)*100; printf(%d\n%d\n,res1,res2); }- Hide quoted text - - Show quoted text - -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Shubham Maheshwari ShubZz O.o o.O enJoY ...!!!- Hide quoted text - - Show quoted text - -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] MICROSOFT
@piyush, @sourabh I also think that array would be a better choice than a linked list. General strategy is take input as string and place digits in suitable size array. Upto this point its ok, but are we required to implement the +,-,/,* or comparison operators also? On Sun, Jul 17, 2011 at 5:24 PM, sourabh jakhar sourabhjak...@gmail.comwrote: we can also use dynamically allocated array where they contain the digits of number and than apply the operation it is a better option i think as we can go to any index in 0(1) time. On Sun, Jul 17, 2011 at 5:19 PM, Harshal hc4...@gmail.com wrote: thanks sourabh :) On Sun, Jul 17, 2011 at 5:17 PM, sourabh jakhar sourabhjak...@gmail.comwrote: 10 c output question . questions were moderate type but negative marking +3 and -2.(30 min) coding round.(45 min) 1.array simple question d.p 2.test cases of notepad 3.Design Big Int class in C or c++ On Sun, Jul 17, 2011 at 5:14 PM, Harshal hc4...@gmail.com wrote: @manish, can you please tell other questions asked by ms today? On Sun, Jul 17, 2011 at 4:53 PM, Piyush Sinha ecstasy.piy...@gmail.com wrote: It can be done using one extra array only that is the output array out[] *int out = (int *)malloc(sizeof(n)); //n is the number of elements in a int i,temp = 1; for(i=0;in;i++) { out[i] = temp; temp*=a[i]; } temp =1; for(i=n-1;i=0;i--) { out[i] *= temp; temp*=a[i]; }* On Sun, Jul 17, 2011 at 4:43 PM, manish patel manispatel...@gmail.com wrote: thanx the question was asked by MS today in MNNIT. On Sun, Jul 17, 2011 at 4:35 PM, Anurag Aggarwal anurag19aggar...@gmail.com wrote: take two extra arrays b[] and c[] in b[] store the following thing b[0]=1; b[i]=b[i-1]*a[i-1]; in c[] store following things c[n-1]=1; c[i]=c[i+1]*a[i+1] (in-1) fill the c[] array in reverse order i.e. start from n-1 then go to 0; now output[] would be output[i]=b[i]*c[i]; On Sun, Jul 17, 2011 at 4:28 PM, geek forgeek geekhori...@gmail.com wrote: given an array a[0..n-1] .required to find the output array out [0.n-1] such that out [i] is the product of all the numbers a[0] to a[n-1] excluding a[i] for ex out[2]=a[0]*a[1]*a[3]*a[4]a[n-1] constraint is not using division operator how to do this in O(n)?? -- 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 http://groups.google.com/group/algogeeks?hl=en. Anurag Aggarwal -- 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 http://groups.google.com/group/algogeeks?hl=en. -- With Regards Manish Patel BTech 2nd Year Computer Science And Engineering National Institute of Technology -Allahabad -- 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 http://groups.google.com/group/algogeeks?hl=en. -- *Piyush Sinha* *IIIT, Allahabad* *+91-7483122727* * https://www.facebook.com/profile.php?id=10655377926 NEVER SAY NEVER * -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Best Regards, Harshal Choudhary 7th Semester, CSE Dept. NIT Surathkal, India. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- SOURABH JAKHAR,(CSE)(3 year) ROOM NO 167 , TILAK,HOSTEL 'MNNIT ALLAHABAD The Law of Win says, Let's not do it your way or my way; let's do it the best way. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Best
Re: [algogeeks] MICROSOFT
when we have + and - than we can also implement division as we do in assembly language subtract the divisor form dividend and keep track of remainder On Sun, Jul 17, 2011 at 5:34 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: @AnchalI think + - and * wont create much problemwe have to think for an efficient way for division -- *Piyush Sinha* *IIIT, Allahabad* *+91-7483122727* * https://www.facebook.com/profile.php?id=10655377926 NEVER SAY NEVER * -- 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 http://groups.google.com/group/algogeeks?hl=en. -- SOURABH JAKHAR,(CSE)(Final year) ROOM NO 167 , TILAK,HOSTEL 'MNNIT ALLAHABAD The Law of Win says, Let's not do it your way or my way; let's do it the best way. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
@sagar pareek: we cant use linked list ah?? On Sun, Jul 17, 2011 at 6:44 PM, sagar pareek sagarpar...@gmail.com wrote: kk... On Sun, Jul 17, 2011 at 5:31 PM, sourabh jakhar sourabhjak...@gmail.comwrote: @sagar pareek if you are from mnnit than donot disclose these kind of things here . On Sun, Jul 17, 2011 at 5:28 PM, sagar pareek sagarpar...@gmail.comwrote: @prasanth Trie will be used... :) :) On Sun, Jul 17, 2011 at 5:28 PM, sagar pareek sagarpar...@gmail.comwrote: @saurabh Ok... on 20th amazon is coming :) On Sun, Jul 17, 2011 at 4:35 PM, prasanth n nprasnt...@gmail.comwrote: @sourabh jakhar: how to design that big int class?? what data structure to use?? On Sun, Jul 17, 2011 at 3:55 PM, sourabh jakhar sourabhjak...@gmail.com wrote: i donot know abt the results but one thing for sure get your basic first right and than do the weird question On Sun, Jul 17, 2011 at 3:53 PM, sagar pareek sagarpar...@gmail.comwrote: Yeah best of luck saurabh whaen results will be out? On Sun, Jul 17, 2011 at 3:47 PM, sourabh jakhar sourabhjak...@gmail.com wrote: hey today ms visited our campus they asked simple 10 c output in first round and than 45 minutes coding round one question on test case on notepad,design bigint class,one simple question on array. On Sun, Jul 17, 2011 at 3:42 PM, sagar pareek sagarpar...@gmail.com wrote: @reynaled :- Happy to help @Sameer :- Thanks for pointing out and i think all you guyz now can optimize it :) On Sun, Jul 17, 2011 at 11:35 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: The question says Algo should be in place. So use of an array to print the right border of tree is not advisable. We can do it recursively without using an array also . On Sat, Jul 16, 2011 at 10:48 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed twice. otherwise it is fine. On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.com wrote: please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.com wrote: Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.com wrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.com wrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.com wrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- 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 http://groups.google.com/group/algogeeks?hl=en. -- You
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
yeah it can be On Sun, Jul 17, 2011 at 6:47 PM, prasanth n nprasnt...@gmail.com wrote: @sagar pareek: we cant use linked list ah?? On Sun, Jul 17, 2011 at 6:44 PM, sagar pareek sagarpar...@gmail.comwrote: kk... On Sun, Jul 17, 2011 at 5:31 PM, sourabh jakhar sourabhjak...@gmail.comwrote: @sagar pareek if you are from mnnit than donot disclose these kind of things here . On Sun, Jul 17, 2011 at 5:28 PM, sagar pareek sagarpar...@gmail.comwrote: @prasanth Trie will be used... :) :) On Sun, Jul 17, 2011 at 5:28 PM, sagar pareek sagarpar...@gmail.comwrote: @saurabh Ok... on 20th amazon is coming :) On Sun, Jul 17, 2011 at 4:35 PM, prasanth n nprasnt...@gmail.comwrote: @sourabh jakhar: how to design that big int class?? what data structure to use?? On Sun, Jul 17, 2011 at 3:55 PM, sourabh jakhar sourabhjak...@gmail.com wrote: i donot know abt the results but one thing for sure get your basic first right and than do the weird question On Sun, Jul 17, 2011 at 3:53 PM, sagar pareek sagarpar...@gmail.com wrote: Yeah best of luck saurabh whaen results will be out? On Sun, Jul 17, 2011 at 3:47 PM, sourabh jakhar sourabhjak...@gmail.com wrote: hey today ms visited our campus they asked simple 10 c output in first round and than 45 minutes coding round one question on test case on notepad,design bigint class,one simple question on array. On Sun, Jul 17, 2011 at 3:42 PM, sagar pareek sagarpar...@gmail.com wrote: @reynaled :- Happy to help @Sameer :- Thanks for pointing out and i think all you guyz now can optimize it :) On Sun, Jul 17, 2011 at 11:35 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: The question says Algo should be in place. So use of an array to print the right border of tree is not advisable. We can do it recursively without using an array also . On Sat, Jul 16, 2011 at 10:48 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed twice. otherwise it is fine. On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.com wrote: please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.com wrote: Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.com wrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.com wrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.com wrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- 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
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
@sagar pareek: thanks On Sun, Jul 17, 2011 at 6:50 PM, sagar pareek sagarpar...@gmail.com wrote: yeah it can be On Sun, Jul 17, 2011 at 6:47 PM, prasanth n nprasnt...@gmail.com wrote: @sagar pareek: we cant use linked list ah?? On Sun, Jul 17, 2011 at 6:44 PM, sagar pareek sagarpar...@gmail.comwrote: kk... On Sun, Jul 17, 2011 at 5:31 PM, sourabh jakhar sourabhjak...@gmail.com wrote: @sagar pareek if you are from mnnit than donot disclose these kind of things here . On Sun, Jul 17, 2011 at 5:28 PM, sagar pareek sagarpar...@gmail.comwrote: @prasanth Trie will be used... :) :) On Sun, Jul 17, 2011 at 5:28 PM, sagar pareek sagarpar...@gmail.comwrote: @saurabh Ok... on 20th amazon is coming :) On Sun, Jul 17, 2011 at 4:35 PM, prasanth n nprasnt...@gmail.comwrote: @sourabh jakhar: how to design that big int class?? what data structure to use?? On Sun, Jul 17, 2011 at 3:55 PM, sourabh jakhar sourabhjak...@gmail.com wrote: i donot know abt the results but one thing for sure get your basic first right and than do the weird question On Sun, Jul 17, 2011 at 3:53 PM, sagar pareek sagarpar...@gmail.com wrote: Yeah best of luck saurabh whaen results will be out? On Sun, Jul 17, 2011 at 3:47 PM, sourabh jakhar sourabhjak...@gmail.com wrote: hey today ms visited our campus they asked simple 10 c output in first round and than 45 minutes coding round one question on test case on notepad,design bigint class,one simple question on array. On Sun, Jul 17, 2011 at 3:42 PM, sagar pareek sagarpar...@gmail.com wrote: @reynaled :- Happy to help @Sameer :- Thanks for pointing out and i think all you guyz now can optimize it :) On Sun, Jul 17, 2011 at 11:35 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: The question says Algo should be in place. So use of an array to print the right border of tree is not advisable. We can do it recursively without using an array also . On Sat, Jul 16, 2011 at 10:48 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed twice. otherwise it is fine. On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.com wrote: please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.com wrote: Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.com wrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.com wrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.com wrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
can anyone pls tell me how to print 2D array in spiral manner?/ On 7/17/11, prasanth n nprasnt...@gmail.com wrote: @sagar pareek: thanks On Sun, Jul 17, 2011 at 6:50 PM, sagar pareek sagarpar...@gmail.com wrote: yeah it can be On Sun, Jul 17, 2011 at 6:47 PM, prasanth n nprasnt...@gmail.com wrote: @sagar pareek: we cant use linked list ah?? On Sun, Jul 17, 2011 at 6:44 PM, sagar pareek sagarpar...@gmail.comwrote: kk... On Sun, Jul 17, 2011 at 5:31 PM, sourabh jakhar sourabhjak...@gmail.com wrote: @sagar pareek if you are from mnnit than donot disclose these kind of things here . On Sun, Jul 17, 2011 at 5:28 PM, sagar pareek sagarpar...@gmail.comwrote: @prasanth Trie will be used... :) :) On Sun, Jul 17, 2011 at 5:28 PM, sagar pareek sagarpar...@gmail.comwrote: @saurabh Ok... on 20th amazon is coming :) On Sun, Jul 17, 2011 at 4:35 PM, prasanth n nprasnt...@gmail.comwrote: @sourabh jakhar: how to design that big int class?? what data structure to use?? On Sun, Jul 17, 2011 at 3:55 PM, sourabh jakhar sourabhjak...@gmail.com wrote: i donot know abt the results but one thing for sure get your basic first right and than do the weird question On Sun, Jul 17, 2011 at 3:53 PM, sagar pareek sagarpar...@gmail.com wrote: Yeah best of luck saurabh whaen results will be out? On Sun, Jul 17, 2011 at 3:47 PM, sourabh jakhar sourabhjak...@gmail.com wrote: hey today ms visited our campus they asked simple 10 c output in first round and than 45 minutes coding round one question on test case on notepad,design bigint class,one simple question on array. On Sun, Jul 17, 2011 at 3:42 PM, sagar pareek sagarpar...@gmail.com wrote: @reynaled :- Happy to help @Sameer :- Thanks for pointing out and i think all you guyz now can optimize it :) On Sun, Jul 17, 2011 at 11:35 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: The question says Algo should be in place. So use of an array to print the right border of tree is not advisable. We can do it recursively without using an array also . On Sat, Jul 16, 2011 at 10:48 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed twice. otherwise it is fine. On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.com wrote: please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.com wrote: Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.com wrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.com wrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.com wrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- You received this message because
[algogeeks] Re: Reverse a List with Recursion
I am looking for a solution with no 'tail' node available/static types used etc. Also with algorithms given without above two conditions, i don't see they doing the right thing for me. Maybe i need to check more. Have you guys tried to see if this is working for you? On Jul 17, 4:42 pm, bharath kannan bharathgo...@gmail.com wrote: node * reverse(node *head) { if(head-next) { node * temp=reverse(head-next); head-next-next=head; head-next=NULL; return temp; } return head; } On Sun, Jul 17, 2011 at 4:57 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: *node *reverse(node *head) { if(head==NULL) return head; if(head-next==NULL) return head; node *temp = reverse(head-next); head-next-next = head; head-next = NULL; return (temp); }* On Sun, Jul 17, 2011 at 4:30 PM, Anika Jain anika.jai...@gmail.comwrote: initial call to this will be rev(head); On Sun, Jul 17, 2011 at 4:28 PM, Anika Jain anika.jai...@gmail.comwrote: node *listing::rev(node *p) { if(p-next==NULL) { head=p; return p; } else { node *t=rev(p-next); t-next=p; p-next=NULL; tail=p; return p; } } On Sun, Jul 17, 2011 at 3:21 PM, Nishant Mittal mittal.nishan...@gmail.com wrote: void rev_recursion(NODE **head) { if(*head==NULL) return; NODE *first, *rest; first=*head; rest=first-next; if(!rest) return; rev_recursion(rest); first-next-next=first; first-next=NULL; *head=rest; } On Sun, Jul 17, 2011 at 2:53 PM, vaibhav shukla vaibhav200...@gmail.com wrote: struct node *reverse_recurse(struct node *start) { if(start-next) { reverse_recurse(start-next); start-next-next=start; return(start); } else { head=start; } } in main if(head) { temp = reverse_recurse(head); temp-next =NULL; } head and temp are global On Sun, Jul 17, 2011 at 2:42 PM, Navneet Gupta navneetn...@gmail.comwrote: Hi, I was trying to accomplish this task with the following call , header = ReverseList(header) I don't want to pass tail pointer or anything and just want that i get a reversed list with new header properly assigned after this call. I am getting issues in corner conditions like returning the correct node to be assigned to header. Can anyone give an elegant solution with above requirement? Since it is with recursion, please test for multiple scenarios (empty list, one node list, twe nodes list etc) before posting your solution. In case of empty list, the procedure should report that. -- Regards, Navneet -- 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 http://groups.google.com/group/algogeeks?hl=en. -- best wishes!! Vaibhav Shukla DU-MCA -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- *Piyush Sinha* *IIIT, Allahabad* *+91-7483122727* * https://www.facebook.com/profile.php?id=10655377926 NEVER SAY NEVER * -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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
Re: [algogeeks] MICROSOFT
@manish-can u plz give more details about the Big Int class ques??what exactly was d ques? On Sun, Jul 17, 2011 at 5:38 PM, sourabh jakhar sourabhjak...@gmail.comwrote: when we have + and - than we can also implement division as we do in assembly language subtract the divisor form dividend and keep track of remainder On Sun, Jul 17, 2011 at 5:34 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: @AnchalI think + - and * wont create much problemwe have to think for an efficient way for division -- *Piyush Sinha* *IIIT, Allahabad* *+91-7483122727* * https://www.facebook.com/profile.php?id=10655377926 NEVER SAY NEVER * -- 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 http://groups.google.com/group/algogeeks?hl=en. -- SOURABH JAKHAR,(CSE)(Final year) ROOM NO 167 , TILAK,HOSTEL 'MNNIT ALLAHABAD The Law of Win says, Let's not do it your way or my way; let's do it the best way. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Archita Monga -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] MS question
1.while typing it must show most popular searches starting from the string which we have typed so far 2.it must show most popular websites first 3.it must show related searches there can be many more On Sun, Jul 17, 2011 at 8:05 PM, swetha rahul swetharahu...@gmail.comwrote: Write testcases for MSN search engine? help me to answer this... also can someone tell me how to answer this type of questions? -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] MS question
1. If u entered nothing and just pressed search, it should display nothing. 2. If u just entered a space and just pressed search, it should display nothing. 3.Verify the results are really related to give word or not 4.Check if proper Result is displayed for key word. 5. Check for the Order of the Result set, whether most relevant results are displayed first. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] MS question
ya got it..thanks... how abt test cases for program to check whether a given string is palindrome or not..? On Sun, Jul 17, 2011 at 8:35 PM, ankit sambyal ankitsamb...@gmail.comwrote: 1. If u entered nothing and just pressed search, it should display nothing. 2. If u just entered a space and just pressed search, it should display nothing. 3.Verify the results are really related to give word or not 4.Check if proper Result is displayed for key word. 5. Check for the Order of the Result set, whether most relevant results are displayed first. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: MS question
1.If string is NULL then it should return 1 i.e. string is palindrome 2.If there is only one character in string then it is palindrome 3.If reverse of given string is same as string On Jul 17, 8:18 pm, swetha rahul swetharahu...@gmail.com wrote: ya got it..thanks... how abt test cases for program to check whether a given string is palindrome or not..? On Sun, Jul 17, 2011 at 8:35 PM, ankit sambyal ankitsamb...@gmail.comwrote: 1. If u entered nothing and just pressed search, it should display nothing. 2. If u just entered a space and just pressed search, it should display nothing. 3.Verify the results are really related to give word or not 4.Check if proper Result is displayed for key word. 5. Check for the Order of the Result set, whether most relevant results are displayed first. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Median of billion numbers - Map Reduce
Given billions of integers in a file. Memory Constraints exist so need to parallelize. One solution can be to split the file over a 100 machines and each machine calculates median of their part using quickselect and sends the result to host machine. Now the host calculates median of these medians and asks the sub machines to discard all the numbers less than this final median. So, map reduce! Now i want to do something like this - Each sub machine has billion/100 integers. It chooses an integer k randomly and divides its integers into two parts, one is less than k and other set is more than k (like quickselect algo). This machine returns to the host basically 3 things, one is k, second and third is number of elements in both sets. After having all that data from submachines, the host does some calculation and asks each machine to discard either the less than set or more than set. then whole thing is repeated with lesser number of elements. Any ideas about how the host machine would do that and on what basis? -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: MS question
is this ans sufficient..? any other possible test cases for palindrome ? On Sun, Jul 17, 2011 at 8:53 PM, Nishant mittal.nishan...@gmail.com wrote: 1.If string is NULL then it should return 1 i.e. string is palindrome 2.If there is only one character in string then it is palindrome 3.If reverse of given string is same as string On Jul 17, 8:18 pm, swetha rahul swetharahu...@gmail.com wrote: ya got it..thanks... how abt test cases for program to check whether a given string is palindrome or not..? On Sun, Jul 17, 2011 at 8:35 PM, ankit sambyal ankitsamb...@gmail.com wrote: 1. If u entered nothing and just pressed search, it should display nothing. 2. If u just entered a space and just pressed search, it should display nothing. 3.Verify the results are really related to give word or not 4.Check if proper Result is displayed for key word. 5. Check for the Order of the Result set, whether most relevant results are displayed first. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Microsoft Interview Qn
plz give some example..sry but what do you mean by child sibling version?? On Jul 16, 3:46 pm, Reynald reynaldsus...@gmail.com wrote: Given a Parent -Child binary tree ,build the child -sibling version of it? Minimize the space requirements wherever possible. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Puzzle
thanks sagar for this wonderful shortcut but can you please explain it better. in what cases can we use this approach? -- 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 http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: MS question
Well, for the third case, you can elaborate on the implementation. We need to compare the first half with the later half. So, in case of even no. of characters it splits perfectly and in case of odd number of characters, just ignore the middle character. On Jul 17, 8:28 pm, swetha rahul swetharahu...@gmail.com wrote: is this ans sufficient..? any other possible test cases for palindrome ? On Sun, Jul 17, 2011 at 8:53 PM, Nishant mittal.nishan...@gmail.com wrote: 1.If string is NULL then it should return 1 i.e. string is palindrome 2.If there is only one character in string then it is palindrome 3.If reverse of given string is same as string On Jul 17, 8:18 pm, swetha rahul swetharahu...@gmail.com wrote: ya got it..thanks... how abt test cases for program to check whether a given string is palindrome or not..? On Sun, Jul 17, 2011 at 8:35 PM, ankit sambyal ankitsamb...@gmail.com wrote: 1. If u entered nothing and just pressed search, it should display nothing. 2. If u just entered a space and just pressed search, it should display nothing. 3.Verify the results are really related to give word or not 4.Check if proper Result is displayed for key word. 5. Check for the Order of the Result set, whether most relevant results are displayed first. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text - - Show quoted text - -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Puzzle
Well you can find it in WILLIAM STALLINGS's book of cryptography. or foundation of cryptography by wenbo mao :) :) On Sun, Jul 17, 2011 at 9:02 PM, Tushar Bindal tushicom...@gmail.comwrote: thanks sagar for this wonderful shortcut but can you please explain it better. in what cases can we use this approach? -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Microsoft Interview Qn
im a bit confused with child-sibling term, this expects output for input: A /\ B C / \ / \ DE F G output: A / B C / / DE FG -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Microsoft Interview Qn
1. PUSH ROOT IN Q 2. PUSH DUMMY NODE IN Q, DEFINE PREVIOUS NODE AS NULL 3. WHILE Q IS NOT EMPTY 3A. POP CURRENT NODE 3B. IF CURRENT NODE IS NOT DUMMY 3B1. IF PREVIOUS, PREVIOUS-SIBLING = CURRENT. 3B2. PREVIOUS = CURRENT 3B3. PUSH CURRENT-LEFT, CURRENT-RIGHT TO Q (ONLY IF THE NODES ARE NOT NULL) 3C IF CURRENT NODE IS DUMMY 3C1 IF PREVIOUS, PREVIOUS-SIBLING = NULL; 3C2 PUSH DUMMY ON Q Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Sat, Jul 16, 2011 at 4:16 PM, Reynald reynaldsus...@gmail.com wrote: Given a Parent -Child binary tree ,build the child -sibling version of it? Minimize the space requirements wherever possible. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Median of billion numbers - Map Reduce
WOULDN'T MEDIAN OF MEDIANS WORK? mappers and reducers using hadoop Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Sun, Jul 17, 2011 at 8:57 PM, Dumanshu duman...@gmail.com wrote: Given billions of integers in a file. Memory Constraints exist so need to parallelize. One solution can be to split the file over a 100 machines and each machine calculates median of their part using quickselect and sends the result to host machine. Now the host calculates median of these medians and asks the sub machines to discard all the numbers less than this final median. So, map reduce! Now i want to do something like this - Each sub machine has billion/100 integers. It chooses an integer k randomly and divides its integers into two parts, one is less than k and other set is more than k (like quickselect algo). This machine returns to the host basically 3 things, one is k, second and third is number of elements in both sets. After having all that data from submachines, the host does some calculation and asks each machine to discard either the less than set or more than set. then whole thing is repeated with lesser number of elements. Any ideas about how the host machine would do that and on what basis? -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Puzzle
thankyou :) -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] c++ output
@sourabh are you sure the code int main() { g(); f(); } inline int f(){ g(); return g()+1; } inline int g() { return 1; } does work i think i must give compilation error. Because a function need to be declared, before it is called in case of c++. and by inline the code in the function is replaced when it is called. On Wed, Jun 8, 2011 at 8:31 PM, hary rathor harry.rat...@gmail.com wrote: because compiler have know about g funtion while evaluating f -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Varun Pahwa B.Tech (IT) 7th Sem. Indian Institute of Information Technology Allahabad. Ph : 09793899112 Official Email :: rit2008...@iiita.ac.in Another Email :: varunpahwa.ii...@gmail.com People who fail to plan are those who plan to fail. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: MS question
check for query injection,string like (spaces,nothing) entered. On Sun, Jul 17, 2011 at 9:04 PM, Dumanshu duman...@gmail.com wrote: Well, for the third case, you can elaborate on the implementation. We need to compare the first half with the later half. So, in case of even no. of characters it splits perfectly and in case of odd number of characters, just ignore the middle character. On Jul 17, 8:28 pm, swetha rahul swetharahu...@gmail.com wrote: is this ans sufficient..? any other possible test cases for palindrome ? On Sun, Jul 17, 2011 at 8:53 PM, Nishant mittal.nishan...@gmail.com wrote: 1.If string is NULL then it should return 1 i.e. string is palindrome 2.If there is only one character in string then it is palindrome 3.If reverse of given string is same as string On Jul 17, 8:18 pm, swetha rahul swetharahu...@gmail.com wrote: ya got it..thanks... how abt test cases for program to check whether a given string is palindrome or not..? On Sun, Jul 17, 2011 at 8:35 PM, ankit sambyal ankitsamb...@gmail.com wrote: 1. If u entered nothing and just pressed search, it should display nothing. 2. If u just entered a space and just pressed search, it should display nothing. 3.Verify the results are really related to give word or not 4.Check if proper Result is displayed for key word. 5. Check for the Order of the Result set, whether most relevant results are displayed first. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text - - Show quoted text - -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: MS question
Check for case senstivity also: eg: Madam and madam both are palindromes. Also for clarify with the interviewer whether whitespace and punctuation can be ignored. eg: is the following string a palindrome or not: A man, a plan, a canal, Panama And check for this condition accordingly -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Reverse a List with Recursion
@Navneet: Its not possible to solve this without a single tail pointer. I have come across this question saying it requires a single pointer and that pointer is the tail pointer. So along with head you need a tail pointer or a global pointer. Otherwise cannot keep track of header for reversed list. On Sun, Jul 17, 2011 at 6:57 PM, Navneet navneetn...@gmail.com wrote: I am looking for a solution with no 'tail' node available/static types used etc. Also with algorithms given without above two conditions, i don't see they doing the right thing for me. Maybe i need to check more. Have you guys tried to see if this is working for you? On Jul 17, 4:42 pm, bharath kannan bharathgo...@gmail.com wrote: node * reverse(node *head) { if(head-next) { node * temp=reverse(head-next); head-next-next=head; head-next=NULL; return temp; } return head; } On Sun, Jul 17, 2011 at 4:57 PM, Piyush Sinha ecstasy.piy...@gmail.com wrote: *node *reverse(node *head) { if(head==NULL) return head; if(head-next==NULL) return head; node *temp = reverse(head-next); head-next-next = head; head-next = NULL; return (temp); }* On Sun, Jul 17, 2011 at 4:30 PM, Anika Jain anika.jai...@gmail.com wrote: initial call to this will be rev(head); On Sun, Jul 17, 2011 at 4:28 PM, Anika Jain anika.jai...@gmail.com wrote: node *listing::rev(node *p) { if(p-next==NULL) { head=p; return p; } else { node *t=rev(p-next); t-next=p; p-next=NULL; tail=p; return p; } } On Sun, Jul 17, 2011 at 3:21 PM, Nishant Mittal mittal.nishan...@gmail.com wrote: void rev_recursion(NODE **head) { if(*head==NULL) return; NODE *first, *rest; first=*head; rest=first-next; if(!rest) return; rev_recursion(rest); first-next-next=first; first-next=NULL; *head=rest; } On Sun, Jul 17, 2011 at 2:53 PM, vaibhav shukla vaibhav200...@gmail.com wrote: struct node *reverse_recurse(struct node *start) { if(start-next) { reverse_recurse(start-next); start-next-next=start; return(start); } else { head=start; } } in main if(head) { temp = reverse_recurse(head); temp-next =NULL; } head and temp are global On Sun, Jul 17, 2011 at 2:42 PM, Navneet Gupta navneetn...@gmail.comwrote: Hi, I was trying to accomplish this task with the following call , header = ReverseList(header) I don't want to pass tail pointer or anything and just want that i get a reversed list with new header properly assigned after this call. I am getting issues in corner conditions like returning the correct node to be assigned to header. Can anyone give an elegant solution with above requirement? Since it is with recursion, please test for multiple scenarios (empty list, one node list, twe nodes list etc) before posting your solution. In case of empty list, the procedure should report that. -- Regards, Navneet -- 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 http://groups.google.com/group/algogeeks?hl=en. -- best wishes!! Vaibhav Shukla DU-MCA -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- *Piyush Sinha* *IIIT, Allahabad* *+91-7483122727* *
[algogeeks] C Doubts
1.When I declare a variable as const then any subsequent assignment of it gives an error assignment of read only variable. Is a const variable treated as a read only variable? 2. #includestdio.h struct s1 { char a; }; char s2 { char b; int c; }; printf(%d,sizeof(struct s1)); // output : 1 printf(%d,sizeof(struct s2)); // output : 8 please explain.. -- 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/-/nOK4AkuAgW8J. 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] C Doubts
1. Yes, you cannot modify a const variable. This itself means that it is read-only. 2.Google structure padding. It is done to make sure that variables start in memory at addresses that are a multiple of their size. This is more efficient at hardware level. 'char' (1 byte) variables can be byte aligned and appear at any byte boundary. 'int' (4 byte) variables must be 4 byte aligned ( they can only appear at byte boundarys that are a multiple of 4 bytes). So, here char b --- At any available byte int c -- 3 bytes from b. So, a total of 1+3+4 = 8 bytes. On Sun, Jul 17, 2011 at 11:38 PM, Abhi abhi123khat...@gmail.com wrote: 1.When I declare a variable as const then any subsequent assignment of it gives an error assignment of read only variable. Is a const variable treated as a read only variable? 2. #includestdio.h struct s1 { char a; }; char s2 { char b; int c; }; printf(%d,sizeof(struct s1)); // output : 1 printf(%d,sizeof(struct s2)); // output : 8 please explain.. -- 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/-/nOK4AkuAgW8J. 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 http://groups.google.com/group/algogeeks?hl=en. -- Best Regards, Harshal Choudhary 7th Semester, CSE Dept. NIT Surathkal, India. The road to knowledge runs through the land of confusion. Mobile: +91 9844667142 Email : hc4...@gmail.com http://www.facebook.com/profile.php?id=1518764305 https://twitter.com/#!/harshal4342 http://www.linkedin.com/pub/harshal-choudhary/17/731/291 http://kkoolharshal.blogspot.com -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] C Doubts
1) you cannot change the const variable . 2) generally sizeof behaviour in case of structure is just undefined. Either it follows the summation of size of members or it uses padding concept ie in your example 4 byte each for character(1 byte for char rest of the 3 bytes is padded up) and 4 byte for integer .This is more efficient On Sun, Jul 17, 2011 at 11:38 PM, Abhi abhi123khat...@gmail.com wrote: 1.When I declare a variable as const then any subsequent assignment of it gives an error assignment of read only variable. Is a const variable treated as a read only variable? 2. #includestdio.h struct s1 { char a; }; char s2 { char b; int c; }; printf(%d,sizeof(struct s1)); // output : 1 printf(%d,sizeof(struct s2)); // output : 8 please explain.. -- 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/-/nOK4AkuAgW8J. 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] C Doubts
That was really helpful. -- 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/-/KvxrTcPf104J. 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 http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: C Doubts
@Abhi: Answers: 1. whenever a 'const' qualifier is added previously to a variable declaration it means that the value of the variable is automatically initialized to '0'(because of the 'auto' type of the const variable) and cannot be changed in any of the following assignment statements to the const variable. 2. Here for the structure struct s1 since the entire structure is ending within 8 bytes no padding is done which means s1: [char a] 1byte but for the structure struct s2 consider the following: s2: [ char a 1byte -- int a--- --4bytes] so here the concept of padding comes to make all the variable aligned in even boundaries and so the structure after aligning will look as: s2: [ -- char b --4byte- -- int a--- --4bytes] so the size of strcut s2 will be 8bytes.. -- 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/-/FoHpgvrjnm0J. 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] c++ output
@varun you are contradicting your own statement when inline replaces the code at place where it is called, then this code will work fine. and the other one w/o inline won't as explained by others also. there seems to be some confusion in your statement. -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tushicom...@gmail.com Website: www.jugadengg.com -- 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 http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: c++ output
The keyword inline means the code is substituted for the declared inline function call in its place itself and this is done at compile time and mostly an optional one left to the compiler to substitute or not. since you have used inline in the snippet it means i checks for the function definition during compile time itself and substitutes the code of inline void f() in the place of f() within the main.So there wont be any problem. but if you remove the keyword inline then it become an ordinary function call.In C, you have to declare or define the function before making a call so that compiler can resolve it as function call.Otherwise it treats the 'f() ' as normal variable declaration and throws error... so you can add the lines: void g(); void f(); before the main and you can compile the program. An other criteria would be placing the defintion blocks of functions f() and g() before main() function. -- 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/-/T1c4QQbX83gJ. 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: C Doubts
struct st { char ch1; long double ld; }s; printf(%d,sizeof(s)); //output : 24 (for 32-bit compiler) -as i have mentioned above the behaviour is undefined in case of sizeof (struct) can any one explain me why the padding concept does not work here ?? On Mon, Jul 18, 2011 at 12:13 AM, Parthiban jega...@gmail.com wrote: @Abhi: Answers: 1. whenever a 'const' qualifier is added previously to a variable declaration it means that the value of the variable is automatically initialized to '0'(because of the 'auto' type of the const variable) and cannot be changed in any of the following assignment statements to the const variable. 2. Here for the structure struct s1 since the entire structure is ending within 8 bytes no padding is done which means s1: [char a] 1byte but for the structure struct s2 consider the following: s2: [ char a 1byte -- int a--- --4bytes] so here the concept of padding comes to make all the variable aligned in even boundaries and so the structure after aligning will look as: s2: [ -- char b --4byte- -- int a--- --4bytes] so the size of strcut s2 will be 8bytes.. -- 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/-/FoHpgvrjnm0J. 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: C Doubts
sizeof long double is 12. So padding concept is perfectly working On Mon, Jul 18, 2011 at 12:26 AM, aditya kumar aditya.kumar130...@gmail.com wrote: struct st { char ch1; long double ld; }s; printf(%d,sizeof(s)); //output : 24 (for 32-bit compiler) -as i have mentioned above the behaviour is undefined in case of sizeof (struct) can any one explain me why the padding concept does not work here ?? On Mon, Jul 18, 2011 at 12:13 AM, Parthiban jega...@gmail.com wrote: @Abhi: Answers: 1. whenever a 'const' qualifier is added previously to a variable declaration it means that the value of the variable is automatically initialized to '0'(because of the 'auto' type of the const variable) and cannot be changed in any of the following assignment statements to the const variable. 2. Here for the structure struct s1 since the entire structure is ending within 8 bytes no padding is done which means s1: [char a] 1byte but for the structure struct s2 consider the following: s2: [ char a 1byte -- int a--- --4bytes] so here the concept of padding comes to make all the variable aligned in even boundaries and so the structure after aligning will look as: s2: [ -- char b --4byte- -- int a--- --4bytes] so the size of strcut s2 will be 8bytes.. -- 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/-/FoHpgvrjnm0J. 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: C Doubts
@prateek . can you explain me ?? i dint get padding logic in this example of mine. On Mon, Jul 18, 2011 at 12:30 AM, sagar pareek sagarpar...@gmail.comwrote: sizeof long double is 12. So padding concept is perfectly working On Mon, Jul 18, 2011 at 12:26 AM, aditya kumar aditya.kumar130...@gmail.com wrote: struct st { char ch1; long double ld; }s; printf(%d,sizeof(s)); //output : 24 (for 32-bit compiler) -as i have mentioned above the behaviour is undefined in case of sizeof (struct) can any one explain me why the padding concept does not work here ?? On Mon, Jul 18, 2011 at 12:13 AM, Parthiban jega...@gmail.com wrote: @Abhi: Answers: 1. whenever a 'const' qualifier is added previously to a variable declaration it means that the value of the variable is automatically initialized to '0'(because of the 'auto' type of the const variable) and cannot be changed in any of the following assignment statements to the const variable. 2. Here for the structure struct s1 since the entire structure is ending within 8 bytes no padding is done which means s1: [char a] 1byte but for the structure struct s2 consider the following: s2: [ char a 1byte -- int a--- --4bytes] so here the concept of padding comes to make all the variable aligned in even boundaries and so the structure after aligning will look as: s2: [ -- char b --4byte- -- int a--- --4bytes] so the size of strcut s2 will be 8bytes.. -- 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/-/FoHpgvrjnm0J. 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: MS question
Thanks everyone!! On Sun, Jul 17, 2011 at 10:56 PM, ankit sambyal ankitsamb...@gmail.comwrote: Check for case senstivity also: eg: Madam and madam both are palindromes. Also for clarify with the interviewer whether whitespace and punctuation can be ignored. eg: is the following string a palindrome or not: A man, a plan, a canal, Panama And check for this condition accordingly -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] MS Ques
Hi, Given 2 linked lists L1 and L2 create a linked list that gives the multiplication of the above 2 linked lists. Eg: L1 =1-5 L2 =1-0 Ans must be 1-5-0 -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: C Doubts
@Aditya Here is the padding effect : Address of char : starts anywhere Address of long double : starts at 11 address locations from char variable -- 1+11+12=24 bytes On Mon, Jul 18, 2011 at 1:10 AM, sagar pareek sagarpar...@gmail.com wrote: @aditya actually first see your post, you have written o/p=24 accordingly padding done is perfect. But actually its printing 16. So now question arises of padding and its pareek not prateek :) On Mon, Jul 18, 2011 at 12:38 AM, aditya kumar aditya.kumar130...@gmail.com wrote: @prateek . can you explain me ?? i dint get padding logic in this example of mine. On Mon, Jul 18, 2011 at 12:30 AM, sagar pareek sagarpar...@gmail.comwrote: sizeof long double is 12. So padding concept is perfectly working On Mon, Jul 18, 2011 at 12:26 AM, aditya kumar aditya.kumar130...@gmail.com wrote: struct st { char ch1; long double ld; }s; printf(%d,sizeof(s)); //output : 24 (for 32-bit compiler) -as i have mentioned above the behaviour is undefined in case of sizeof (struct) can any one explain me why the padding concept does not work here ?? On Mon, Jul 18, 2011 at 12:13 AM, Parthiban jega...@gmail.com wrote: @Abhi: Answers: 1. whenever a 'const' qualifier is added previously to a variable declaration it means that the value of the variable is automatically initialized to '0'(because of the 'auto' type of the const variable) and cannot be changed in any of the following assignment statements to the const variable. 2. Here for the structure struct s1 since the entire structure is ending within 8 bytes no padding is done which means s1: [char a] 1byte but for the structure struct s2 consider the following: s2: [ char a 1byte -- int a--- --4bytes] so here the concept of padding comes to make all the variable aligned in even boundaries and so the structure after aligning will look as: s2: [ -- char b --4byte- -- int a--- --4bytes] so the size of strcut s2 will be 8bytes.. -- 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/-/FoHpgvrjnm0J. 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Nikhil Gupta Senior Co-ordinator, Publicity CSI, NSIT Students' Branch NSIT, New Delhi, India -- 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 http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: MICROSOFT
one way is through the log concept: log(A/B)=logA-logB antilog(logA-logB) will give u log(A/B) without using division operator... but this will work iff there is a log function and an antilogfunction in the math.h header file... -- 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/-/i5jBog0xFIQJ. 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: C Doubts
@pareek..my compiler gives 24 . newazz if ansa is 16 acc to you then it follows padding principle perfectly. since memory cycle invloves 1 word hence char will take 1 byte nd 3 bytes will be padded up . rest 12 bytes will come from long double so 4+12=16 bytes :) n ya sry abt d name . On Mon, Jul 18, 2011 at 1:10 AM, sagar pareek sagarpar...@gmail.com wrote: @aditya actually first see your post, you have written o/p=24 accordingly padding done is perfect. But actually its printing 16. So now question arises of padding and its pareek not prateek :) On Mon, Jul 18, 2011 at 12:38 AM, aditya kumar aditya.kumar130...@gmail.com wrote: @prateek . can you explain me ?? i dint get padding logic in this example of mine. On Mon, Jul 18, 2011 at 12:30 AM, sagar pareek sagarpar...@gmail.comwrote: sizeof long double is 12. So padding concept is perfectly working On Mon, Jul 18, 2011 at 12:26 AM, aditya kumar aditya.kumar130...@gmail.com wrote: struct st { char ch1; long double ld; }s; printf(%d,sizeof(s)); //output : 24 (for 32-bit compiler) -as i have mentioned above the behaviour is undefined in case of sizeof (struct) can any one explain me why the padding concept does not work here ?? On Mon, Jul 18, 2011 at 12:13 AM, Parthiban jega...@gmail.com wrote: @Abhi: Answers: 1. whenever a 'const' qualifier is added previously to a variable declaration it means that the value of the variable is automatically initialized to '0'(because of the 'auto' type of the const variable) and cannot be changed in any of the following assignment statements to the const variable. 2. Here for the structure struct s1 since the entire structure is ending within 8 bytes no padding is done which means s1: [char a] 1byte but for the structure struct s2 consider the following: s2: [ char a 1byte -- int a--- --4bytes] so here the concept of padding comes to make all the variable aligned in even boundaries and so the structure after aligning will look as: s2: [ -- char b --4byte- -- int a--- --4bytes] so the size of strcut s2 will be 8bytes.. -- 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/-/FoHpgvrjnm0J. 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: C Doubts
@Sagar Memory sizes of long double variables are compiler and system configuration dependent. So obviously, in accordance with your compiler, the size of long double is 8 bytes. On Mon, Jul 18, 2011 at 1:22 AM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: @Aditya Here is the padding effect : Address of char : starts anywhere Address of long double : starts at 11 address locations from char variable -- 1+11+12=24 bytes On Mon, Jul 18, 2011 at 1:10 AM, sagar pareek sagarpar...@gmail.comwrote: @aditya actually first see your post, you have written o/p=24 accordingly padding done is perfect. But actually its printing 16. So now question arises of padding and its pareek not prateek :) On Mon, Jul 18, 2011 at 12:38 AM, aditya kumar aditya.kumar130...@gmail.com wrote: @prateek . can you explain me ?? i dint get padding logic in this example of mine. On Mon, Jul 18, 2011 at 12:30 AM, sagar pareek sagarpar...@gmail.comwrote: sizeof long double is 12. So padding concept is perfectly working On Mon, Jul 18, 2011 at 12:26 AM, aditya kumar aditya.kumar130...@gmail.com wrote: struct st { char ch1; long double ld; }s; printf(%d,sizeof(s)); //output : 24 (for 32-bit compiler) -as i have mentioned above the behaviour is undefined in case of sizeof (struct) can any one explain me why the padding concept does not work here ?? On Mon, Jul 18, 2011 at 12:13 AM, Parthiban jega...@gmail.com wrote: @Abhi: Answers: 1. whenever a 'const' qualifier is added previously to a variable declaration it means that the value of the variable is automatically initialized to '0'(because of the 'auto' type of the const variable) and cannot be changed in any of the following assignment statements to the const variable. 2. Here for the structure struct s1 since the entire structure is ending within 8 bytes no padding is done which means s1: [char a] 1byte but for the structure struct s2 consider the following: s2: [ char a 1byte -- int a--- --4bytes] so here the concept of padding comes to make all the variable aligned in even boundaries and so the structure after aligning will look as: s2: [ -- char b --4byte- -- int a--- --4bytes] so the size of strcut s2 will be 8bytes.. -- 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/-/FoHpgvrjnm0J. 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Nikhil Gupta Senior Co-ordinator, Publicity CSI, NSIT Students' Branch NSIT, New Delhi, India -- Nikhil Gupta Senior Co-ordinator, Publicity CSI, NSIT Students' Branch NSIT, New Delhi, India -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: C Doubts
@Nikhil why is Address of long double : starts at 11 address locations from char variable ?? is shud start from 3rd adress location from char variable bcoz memory cycle involves a word so are you padding 11bytes ?? On Mon, Jul 18, 2011 at 1:24 AM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: @Sagar Memory sizes of long double variables are compiler and system configuration dependent. So obviously, in accordance with your compiler, the size of long double is 8 bytes. On Mon, Jul 18, 2011 at 1:22 AM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: @Aditya Here is the padding effect : Address of char : starts anywhere Address of long double : starts at 11 address locations from char variable -- 1+11+12=24 bytes On Mon, Jul 18, 2011 at 1:10 AM, sagar pareek sagarpar...@gmail.comwrote: @aditya actually first see your post, you have written o/p=24 accordingly padding done is perfect. But actually its printing 16. So now question arises of padding and its pareek not prateek :) On Mon, Jul 18, 2011 at 12:38 AM, aditya kumar aditya.kumar130...@gmail.com wrote: @prateek . can you explain me ?? i dint get padding logic in this example of mine. On Mon, Jul 18, 2011 at 12:30 AM, sagar pareek sagarpar...@gmail.comwrote: sizeof long double is 12. So padding concept is perfectly working On Mon, Jul 18, 2011 at 12:26 AM, aditya kumar aditya.kumar130...@gmail.com wrote: struct st { char ch1; long double ld; }s; printf(%d,sizeof(s)); //output : 24 (for 32-bit compiler) -as i have mentioned above the behaviour is undefined in case of sizeof (struct) can any one explain me why the padding concept does not work here ?? On Mon, Jul 18, 2011 at 12:13 AM, Parthiban jega...@gmail.comwrote: @Abhi: Answers: 1. whenever a 'const' qualifier is added previously to a variable declaration it means that the value of the variable is automatically initialized to '0'(because of the 'auto' type of the const variable) and cannot be changed in any of the following assignment statements to the const variable. 2. Here for the structure struct s1 since the entire structure is ending within 8 bytes no padding is done which means s1: [char a] 1byte but for the structure struct s2 consider the following: s2: [ char a 1byte -- int a--- --4bytes] so here the concept of padding comes to make all the variable aligned in even boundaries and so the structure after aligning will look as: s2: [ -- char b --4byte- -- int a--- --4bytes] so the size of strcut s2 will be 8bytes.. -- 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/-/FoHpgvrjnm0J. 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Nikhil Gupta Senior Co-ordinator, Publicity CSI, NSIT Students' Branch NSIT, New Delhi, India -- Nikhil Gupta Senior Co-ordinator, Publicity CSI, NSIT Students' Branch NSIT, New Delhi, India -- You received this message because
Re: [algogeeks] Re: C Doubts
That is again compiler dependent. Usually when hardware configuration is taken into account, the compiler uses padding of 3 bytes. But in some cases, for the ease of hardware access and faster implementation, 11 bytes are padded. Possibly depends on your system hardware's synchronization with the compiler. On Mon, Jul 18, 2011 at 1:27 AM, aditya kumar aditya.kumar130...@gmail.comwrote: @Nikhil why is Address of long double : starts at 11 address locations from char variable ?? is shud start from 3rd adress location from char variable bcoz memory cycle involves a word so are you padding 11bytes ?? On Mon, Jul 18, 2011 at 1:24 AM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: @Sagar Memory sizes of long double variables are compiler and system configuration dependent. So obviously, in accordance with your compiler, the size of long double is 8 bytes. On Mon, Jul 18, 2011 at 1:22 AM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: @Aditya Here is the padding effect : Address of char : starts anywhere Address of long double : starts at 11 address locations from char variable -- 1+11+12=24 bytes On Mon, Jul 18, 2011 at 1:10 AM, sagar pareek sagarpar...@gmail.comwrote: @aditya actually first see your post, you have written o/p=24 accordingly padding done is perfect. But actually its printing 16. So now question arises of padding and its pareek not prateek :) On Mon, Jul 18, 2011 at 12:38 AM, aditya kumar aditya.kumar130...@gmail.com wrote: @prateek . can you explain me ?? i dint get padding logic in this example of mine. On Mon, Jul 18, 2011 at 12:30 AM, sagar pareek sagarpar...@gmail.comwrote: sizeof long double is 12. So padding concept is perfectly working On Mon, Jul 18, 2011 at 12:26 AM, aditya kumar aditya.kumar130...@gmail.com wrote: struct st { char ch1; long double ld; }s; printf(%d,sizeof(s)); //output : 24 (for 32-bit compiler) -as i have mentioned above the behaviour is undefined in case of sizeof (struct) can any one explain me why the padding concept does not work here ?? On Mon, Jul 18, 2011 at 12:13 AM, Parthiban jega...@gmail.comwrote: @Abhi: Answers: 1. whenever a 'const' qualifier is added previously to a variable declaration it means that the value of the variable is automatically initialized to '0'(because of the 'auto' type of the const variable) and cannot be changed in any of the following assignment statements to the const variable. 2. Here for the structure struct s1 since the entire structure is ending within 8 bytes no padding is done which means s1: [char a] 1byte but for the structure struct s2 consider the following: s2: [ char a 1byte -- int a--- --4bytes] so here the concept of padding comes to make all the variable aligned in even boundaries and so the structure after aligning will look as: s2: [ -- char b --4byte- -- int a--- --4bytes] so the size of strcut s2 will be 8bytes.. -- 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/-/FoHpgvrjnm0J. 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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
[algogeeks] Re: Median of billion numbers - Map Reduce
it will work. But i want to avoid case of computing the median by sub machines. So as to improve upon the complexity, i want the sub machines to just take a random number k and split their data into two sets and and then pass the information to host machine which after having all the outputs of sub machines tells them to discard or data on basis of something. I want this something. On Jul 17, 8:51 pm, Ashish Goel ashg...@gmail.com wrote: WOULDN'T MEDIAN OF MEDIANS WORK? mappers and reducers using hadoop Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Sun, Jul 17, 2011 at 8:57 PM, Dumanshu duman...@gmail.com wrote: Given billions of integers in a file. Memory Constraints exist so need to parallelize. One solution can be to split the file over a 100 machines and each machine calculates median of their part using quickselect and sends the result to host machine. Now the host calculates median of these medians and asks the sub machines to discard all the numbers less than this final median. So, map reduce! Now i want to do something like this - Each sub machine has billion/100 integers. It chooses an integer k randomly and divides its integers into two parts, one is less than k and other set is more than k (like quickselect algo). This machine returns to the host basically 3 things, one is k, second and third is number of elements in both sets. After having all that data from submachines, the host does some calculation and asks each machine to discard either the less than set or more than set. then whole thing is repeated with lesser number of elements. Any ideas about how the host machine would do that and on what basis? -- 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 http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text - - Show quoted text - -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: C Doubts
@nikhil my compiler gives sizeof long double =12 so aditya's concept is correct On Mon, Jul 18, 2011 at 1:35 AM, aditya kumar aditya.kumar130...@gmail.comwrote: @Nikhil thnks :) On Mon, Jul 18, 2011 at 1:32 AM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: That is again compiler dependent. Usually when hardware configuration is taken into account, the compiler uses padding of 3 bytes. But in some cases, for the ease of hardware access and faster implementation, 11 bytes are padded. Possibly depends on your system hardware's synchronization with the compiler. On Mon, Jul 18, 2011 at 1:27 AM, aditya kumar aditya.kumar130...@gmail.com wrote: @Nikhil why is Address of long double : starts at 11 address locations from char variable ?? is shud start from 3rd adress location from char variable bcoz memory cycle involves a word so are you padding 11bytes ?? On Mon, Jul 18, 2011 at 1:24 AM, Nikhil Gupta nikhilgupta2...@gmail.com wrote: @Sagar Memory sizes of long double variables are compiler and system configuration dependent. So obviously, in accordance with your compiler, the size of long double is 8 bytes. On Mon, Jul 18, 2011 at 1:22 AM, Nikhil Gupta nikhilgupta2...@gmail.com wrote: @Aditya Here is the padding effect : Address of char : starts anywhere Address of long double : starts at 11 address locations from char variable -- 1+11+12=24 bytes On Mon, Jul 18, 2011 at 1:10 AM, sagar pareek sagarpar...@gmail.comwrote: @aditya actually first see your post, you have written o/p=24 accordingly padding done is perfect. But actually its printing 16. So now question arises of padding and its pareek not prateek :) On Mon, Jul 18, 2011 at 12:38 AM, aditya kumar aditya.kumar130...@gmail.com wrote: @prateek . can you explain me ?? i dint get padding logic in this example of mine. On Mon, Jul 18, 2011 at 12:30 AM, sagar pareek sagarpar...@gmail.com wrote: sizeof long double is 12. So padding concept is perfectly working On Mon, Jul 18, 2011 at 12:26 AM, aditya kumar aditya.kumar130...@gmail.com wrote: struct st { char ch1; long double ld; }s; printf(%d,sizeof(s)); //output : 24 (for 32-bit compiler) -as i have mentioned above the behaviour is undefined in case of sizeof (struct) can any one explain me why the padding concept does not work here ?? On Mon, Jul 18, 2011 at 12:13 AM, Parthiban jega...@gmail.comwrote: @Abhi: Answers: 1. whenever a 'const' qualifier is added previously to a variable declaration it means that the value of the variable is automatically initialized to '0'(because of the 'auto' type of the const variable) and cannot be changed in any of the following assignment statements to the const variable. 2. Here for the structure struct s1 since the entire structure is ending within 8 bytes no padding is done which means s1: [char a] 1byte but for the structure struct s2 consider the following: s2: [ char a 1byte -- int a--- --4bytes] so here the concept of padding comes to make all the variable aligned in even boundaries and so the structure after aligning will look as: s2: [ -- char b --4byte- -- int a--- --4bytes] so the size of strcut s2 will be 8bytes.. -- 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/-/FoHpgvrjnm0J. 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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
[algogeeks] In-memory dictionary
I want to have an in-memory dictionary. One word can have multiple meanings. 1. If you want to go with hash tables then do Suggest some good choices for hash functions. 2. Also, how can you modify this dictionary so that it can be used to solve a crossword puzzle? -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: MICROSOFT
assume that ; all element in array are short integer; int i; long long long long long int multi=1; for(i=0;ia.len;i++) { multi*=a[i]; } for(i=0;ia.len;i++) { out[i]=mul[i]/a[i]; } O(n) -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: MICROSOFT
the question also had these words: donot use division operator -- 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/-/87l39yN8v6sJ. 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: MICROSOFT
^*constraint is not using division operator* * * * * On 18 July 2011 01:44, hary rathor harry.rat...@gmail.com wrote: assume that ; all element in array are short integer; int i; long long long long long int multi=1; for(i=0;ia.len;i++) { multi*=a[i]; } for(i=0;ia.len;i++) { out[i]=mul[i]/a[i]; } O(n) -- 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 http://groups.google.com/group/algogeeks?hl=en. -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: MICROSOFT
sorry: i didn't see -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] In-memory dictionary
1. you can use hash function with link list. 2. u can use trie with link list. On Mon, Jul 18, 2011 at 1:43 AM, Dumanshu duman...@gmail.com wrote: I want to have an in-memory dictionary. One word can have multiple meanings. 1. If you want to go with hash tables then do Suggest some good choices for hash functions. 2. Also, how can you modify this dictionary so that it can be used to solve a crossword puzzle? -- 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 http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: MICROSOFT
int dividend,divisor,remainder; int division(int p,int q){ int quotient=1; /*if divisor and diviend are equal then quotient=1*/ if(p==q){ remainder=0; return 1; } /*if dividend is smaller than divisor then remainder=dividend*/ if(pq){ remainder=p; return 0; } /*shift left till divisor dividend*/ while(p=q){ q=1; quotient=1; } /*shift right for one time so that divisor become smaller than dividend*/ q=1; quotient=1; /*again call division recurcively*/ quotient+=division(p-q,divisor); return quotient; } int * demo() { int i; long long long long long int multi=1; for(i=0;ia.len;i++) { multi*=a[i]; } for(i=0;ia.len;i++) { out[i]=mul[i]/a[i]; } } -- 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 http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Microsoft Interview Qn
@Ashish: if i got ur algo correct, contrary to all the above examples, u r forming a linked list of level order traversal of the tree. m i right? On Jul 17, 8:49 pm, Ashish Goel ashg...@gmail.com wrote: 1. PUSH ROOT IN Q 2. PUSH DUMMY NODE IN Q, DEFINE PREVIOUS NODE AS NULL 3. WHILE Q IS NOT EMPTY 3A. POP CURRENT NODE 3B. IF CURRENT NODE IS NOT DUMMY 3B1. IF PREVIOUS, PREVIOUS-SIBLING = CURRENT. 3B2. PREVIOUS = CURRENT 3B3. PUSH CURRENT-LEFT, CURRENT-RIGHT TO Q (ONLY IF THE NODES ARE NOT NULL) 3C IF CURRENT NODE IS DUMMY 3C1 IF PREVIOUS, PREVIOUS-SIBLING = NULL; 3C2 PUSH DUMMY ON Q Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Sat, Jul 16, 2011 at 4:16 PM, Reynald reynaldsus...@gmail.com wrote: Given a Parent -Child binary tree ,build the child -sibling version of it? Minimize the space requirements wherever possible. -- 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 http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text - - Show quoted text - -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] MS Ques
p=L1 q=L2 while(p!=NULL q!=NULL) {int r; r-=p-info*q-info; p=p-next; q=q-next; insert(L3,r); } insert is the normal insert operation of linked list On Mon, Jul 18, 2011 at 1:15 AM, swetha rahul swetharahu...@gmail.comwrote: Hi, Given 2 linked lists L1 and L2 create a linked list that gives the multiplication of the above 2 linked lists. Eg: L1 =1-5 L2 =1-0 Ans must be 1-5-0 -- 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 http://groups.google.com/group/algogeeks?hl=en. -- Aditi Garg Undergraduate Student Electronics Communication Divison NETAJI SUBHAS INSTITUTE OF TECHNOLOGY Sector 3, Dwarka New Delhi 9718388816 -- 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 http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] MS Ques
aditi : problem your code 1 .you are not putting single digit in third list but whole multiplication of two digit 2. forward add carry to next result ; 3. keep mind that list size may not be equal 4. list is singly so start processing from right side you need reverse them -- 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 http://groups.google.com/group/algogeeks?hl=en.