[algogeeks] Median Finding in Sorted Arrays
Hi guys, Please help me in finding median of two sorted arrays of length m and n in minimum possible time. Thanks, Sanjay -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com.
Re: [algogeeks] Re: Highest reminder
23 = 11 * 2 + 1 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com.
Re: [algogeeks] Re: Highest reminder
Hi Ankit, for 23, how can the remainder be 12 ? Can you elaborate more ? *Regards,* *Sanjay Kumar* *Software Engineer(Development)* *Winshuttle Softwares(India) Pvt. Ltd.* *Mobile +91-89012-36292, +91-80535-66286* *Email: sanjay.ku...@winshuttle.com* * *** * * ** * * On Thu, May 30, 2013 at 9:40 AM, Ankit Agarwal ankuagarw...@gmail.comwrote: @Dave: For N = 23, the highest remainder is 12, not 11 On Thu, May 30, 2013 at 5:02 AM, Dave dave_and_da...@juno.com wrote: The highest remainder when dividing n by a number less than n is floor((n-1)/2). For n = 11, floor((11-1)/2) = floor(10/2) = floor(5) = 5. For n = 17, floor((17-1)/2) = 8 For n = 23, floor((23-1)/2) = 11 For n = 12, floor((12-1)/2) = floor(11/2) = floor(5.5) = 5. Etc. Dave On Wednesday, May 29, 2013 1:36:13 PM UTC-5, Ankit wrote: Hi, Number 23: = 11 * 1 + 12 Number/2 = 11.5 Number 17: = 9 * 1 + 8 Number/2 = 8.5 So, its neither floor(n/2) +- 1, nor ceil(n/2) +- 1 On Wed, May 29, 2013 at 2:19 PM, Ankit Sambyal ankitsam...@gmail.comwrote: Hi Nikhil, Highest remainder can't be floor(n/2) - 1. If n = 11, highest remainder would be 5 when it is divided by 6, but your formula gives 4. On Mon, May 27, 2013 at 8:16 PM, Nikhil Kumar niksin...@gmail.comwrote: Since we need to divide so the quotient should be at least 1, and we need greatest remainder, so we need the least no. which will give the quotient 1 upon dividing and that would be the no. you described. Also you would have noted the greatest remainder would be floor(n/2)-1 . On Thursday, 16 May 2013 13:56:40 UTC+5:30, Soumya Prasad Ukil wrote: For a given number when divided by a number between 1 and n. I figured out that highest reminder can be got if I divide the number by (⌊(n/2)⌋+1) .Can anyone give me pointers ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+...@**googlegroups.com. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+...@**googlegroups.com. -- *Ankit Agarwal* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com. -- *Ankit Agarwal* *Software Engineer* *Datacenter Cloud Division* *Citrix RD India Pvt. Ltd.* *Ph. No. +91-8095470278* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com.
[algogeeks] Missing Number Problem
We are given 300 million 9-digit numbers and 2 MB of RAM. We have to find the missing number. How do we approach this problem ? *Regards,* *Sanjay Kumar* * * ** * * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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]
Segmentation fault occurs when you try to access a memory which doesn't belong to your program. You are trying to cast a memory location of one byte to 4 byte(assuming size of long int to be 4). It is possible that other three bytes belong to some other process. That is why you are getting segmentation error. Correct me if m wrong. * * ** * * On Wed, Jul 18, 2012 at 4:55 PM, vindhya chhabra vindhyachha...@gmail.comwrote: is it due to accessing the long at odd address? On Wed, Jul 18, 2012 at 4:54 PM, vindhya chhabra vindhyachha...@gmail.com wrote: #include stdlib.h #include stdio.h int main(void) { char *c; long int *i; c = (char *) malloc(sizeof(char)); c++; i = (long int *)c; printf(%ld, *i); return 0; } please explain how bus error occurs here..i am not clear about bus error and segmentation fault..plz help. -- Vindhya Chhabra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Vindhya Chhabra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] thanx to all
many congratulations :) * Sanjay Kumar * On Wed, Feb 29, 2012 at 10:59 AM, mohit mishra mohit7mis...@gmail.comwrote: congrats :-) On Wed, Feb 29, 2012 at 10:56 AM, shady sinv...@gmail.com wrote: congrats :) keep participating and keep learning. On Wed, Feb 29, 2012 at 9:19 AM, atul anand atul.87fri...@gmail.comwrote: congo :) On Wed, Feb 29, 2012 at 5:30 AM, Varun Nagpal varun.nagp...@gmail.comwrote: cool On Tue, Feb 28, 2012 at 9:22 PM, Ravi Ranjan ravi.cool2...@gmail.comwrote: hey Geeks thanx a lot .. for the valuable information in the discussions i got selected in Yatra.com (R n D profile) thanx a lot for the algorithms explained by to guys THANX A LOT :D:D:D:D -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Literati 2012
LITERATI - the national level annual technical fest of NIT- Kurukshetra(1-4 March 2012) We Promise you 4 days non stop Fun. Mark your presence as a participant, spectator and a witness. For more details, log on to Literati Website http://www.literati.net.inand find us on Facebook http://www.facebook.com/LITERATI2k12 also. * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286 * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Amazon ques
+1 * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286 * On Thu, Jan 26, 2012 at 6:28 PM, Ashish Goel ashg...@gmail.com wrote: replace all 0s by -1 keep additional array to get the sumHere at every position of all -1s and 1s. say you got 0 1 0 1 0 0 0 0 1 1 1 1 0 -1 1 -1 1 -1 -1 -1 -1 1 1 1 1 -1 sum -1 0 -1 0 -1 -2 -3 -4 -3 -2 -1 0 -1 all equal numbers in sum shows equal zeros and 1s between then including the end( between two -2 or two -3 or 0 0r -1) so biggest one can be figured out easily use a hash to store these cum sum, store their first and last occurrence, walk over to get max diff. Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Fri, Jan 27, 2012 at 1:48 AM, algoist krishnai...@gmail.com wrote: Consider 2 temp arrays, B and C Where B gets updated for every find of 0 and C for every find of 1 i.e if(a[i]==0) b[i]+=b[i-1]+1; c[i]=c[i-1]; i.e if(a[i]==1) c[i]+=c[i-1]+1; b[i]=b[i-1]; if(c[i]==b[i]) update max. return max. This is O(N) algo. Is it right or i am missing anything here? -- 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/-/YnKOgIEspAcJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Minimum number of jumps to reach end
Given an array of integers where each element represents the max number of steps that can be made forward from that element. Write a function to return the minimum number of jumps to reach the end of the array (starting from the first element). If an element is 0, then cannot move through that element. Example: *Input: arr[] = {1, 3, 5, 8, 9, 2, 6, 7, 6, 8, 9} Output: 3 (1- 3 - 8 -9)* * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286 * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Lets Discuss About Some More Practical Application of Data Structure Algorithm , Problem Solving - How You WIll The Mutual Friends Between each m*n friends
Sorry to interrupt Guyzz.. I need ur help. I am not getting the Failure Function of Knuth Morris Pratt Algo for string matching... Plz reply asap Thanx in advance. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] KMP Failure Function Problem
Below is the code for KMP failure function : int F[]; //assume F is a global arary. int Fill-Prefix-Table(int P[], int m) { int i,j; F[0]=0; j=0; i=1; while(i m) { if(P[i] == P[j]) { F[i]=j+1; i++; j++; } else if(j 0) { j = F[j-1]; } else { F[i]=0; i++; } } } In the above function, in the else if case, why is it j = F[j-1] ? Plz explain with an example.. Thanx in advance :) * * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] sort 2D array
But the question says without extra space ? How do we do that without space ? * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286 * On Wed, Jan 11, 2012 at 12:24 AM, Ankur Garg ankurga...@gmail.com wrote: @Shady Rows are already sorted ... On Wed, Jan 11, 2012 at 1:53 PM, shady sinv...@gmail.com wrote: ^^ true, sort the rows and then a K-way merge. On Wed, Jan 11, 2012 at 1:00 PM, Sanjay Rajpal sanjay.raj...@live.inwrote: I guess sort the array such that elements are sorted finally in such a way that if we print them row by row, the result is a sorted array. K-way merge can be useful. * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286 * On Tue, Jan 10, 2012 at 11:28 PM, prakash y yprakash@gmail.comwrote: sort the whole matrix in ascending array means? can you please explain ? On Wed, Jan 11, 2012 at 12:53 PM, atul anand atul.87fri...@gmail.comwrote: Given 2D array. The rows are sorted in ascending order and the colums are sorted in ascending order. We have to sort the whole matrix in ascending array. We cannot use extra space. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] sort 2D array
How can it be mn log mn ? it will be O(mn) as we elements are sorted, we simply pick minimum at each iteration of the loop. Since there are mn elements, so complexity will be O(mn). Correct me if m wrong. * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286 * On Wed, Jan 11, 2012 at 12:29 AM, Ankur Garg ankurga...@gmail.com wrote: If we use K merge I think the time complexity would be nm lognm I think we must try doing in O(m*n) On Wed, Jan 11, 2012 at 1:54 PM, Ankur Garg ankurga...@gmail.com wrote: @Shady Rows are already sorted ... On Wed, Jan 11, 2012 at 1:53 PM, shady sinv...@gmail.com wrote: ^^ true, sort the rows and then a K-way merge. On Wed, Jan 11, 2012 at 1:00 PM, Sanjay Rajpal sanjay.raj...@live.inwrote: I guess sort the array such that elements are sorted finally in such a way that if we print them row by row, the result is a sorted array. K-way merge can be useful. * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286 * On Tue, Jan 10, 2012 at 11:28 PM, prakash y yprakash@gmail.comwrote: sort the whole matrix in ascending array means? can you please explain ? On Wed, Jan 11, 2012 at 12:53 PM, atul anand atul.87fri...@gmail.comwrote: Given 2D array. The rows are sorted in ascending order and the colums are sorted in ascending order. We have to sort the whole matrix in ascending array. We cannot use extra space. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] sort 2D array
Where do we store the sorted list ? How do we do it in place ? * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286 * On Wed, Jan 11, 2012 at 12:34 AM, Sanjay Rajpal sanjay.raj...@live.inwrote: How can it be mn log mn ? it will be O(mn) as we elements are sorted, we simply pick minimum at each iteration of the loop. Since there are mn elements, so complexity will be O(mn). Correct me if m wrong. * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286 * On Wed, Jan 11, 2012 at 12:29 AM, Ankur Garg ankurga...@gmail.com wrote: If we use K merge I think the time complexity would be nm lognm I think we must try doing in O(m*n) On Wed, Jan 11, 2012 at 1:54 PM, Ankur Garg ankurga...@gmail.com wrote: @Shady Rows are already sorted ... On Wed, Jan 11, 2012 at 1:53 PM, shady sinv...@gmail.com wrote: ^^ true, sort the rows and then a K-way merge. On Wed, Jan 11, 2012 at 1:00 PM, Sanjay Rajpal sanjay.raj...@live.inwrote: I guess sort the array such that elements are sorted finally in such a way that if we print them row by row, the result is a sorted array. K-way merge can be useful. * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286 * On Tue, Jan 10, 2012 at 11:28 PM, prakash y yprakash@gmail.comwrote: sort the whole matrix in ascending array means? can you please explain ? On Wed, Jan 11, 2012 at 12:53 PM, atul anand atul.87fri...@gmail.com wrote: Given 2D array. The rows are sorted in ascending order and the colums are sorted in ascending order. We have to sort the whole matrix in ascending array. We cannot use extra space. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Maximum size square sub-matrix with all 1s
Suggest an algorithm guyzzz. * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286 * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Maximum size square sub-matrix with all 1s
Its a square matrix containing 0s and 1s. Will u plz elaborate about this equation ? * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286 * On Tue, Jan 10, 2012 at 8:36 AM, atul anand atul.87fri...@gmail.com wrote: i dint get...you should provide more details , if it is all 1 then whole matrix is a max square.. anyways equation to find max sub square is this. M[i,j]=R[i,j]==0 ? 0 : 1+min(M[i-1][,j] , M[i][j-1], M[i-1][j-1] ) On Tue, Jan 10, 2012 at 10:00 PM, Sanjay Rajpal sanjay.raj...@live.inwrote: Suggest an algorithm guyzzz. * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286 * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] sort 2D array
I guess sort the array such that elements are sorted finally in such a way that if we print them row by row, the result is a sorted array. K-way merge can be useful. * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286 * On Tue, Jan 10, 2012 at 11:28 PM, prakash y yprakash@gmail.com wrote: sort the whole matrix in ascending array means? can you please explain ? On Wed, Jan 11, 2012 at 12:53 PM, atul anand atul.87fri...@gmail.comwrote: Given 2D array. The rows are sorted in ascending order and the colums are sorted in ascending order. We have to sort the whole matrix in ascending array. We cannot use extra space. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Binary Search Problem
In binary search, mid = start + (end-start)/2 is used to avoid overflow, as said by a book. why can't we use mid = (start + end)/2, it says this statement may result in overflow ? * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286 * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Binary Search Problem
actually book pages are images. My question is why second statement may result in overflow ? * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286, +91-9729683720 * On Sun, Jan 8, 2012 at 3:07 AM, saurabh singh saurab...@gmail.com wrote: not clear what you are trying to ask...can you quote exactly from the book? Saurabh Singh B.Tech (Computer Science) MNNIT blog:geekinessthecoolway.blogspot.com On Sun, Jan 8, 2012 at 4:34 PM, Sanjay Rajpal srn...@gmail.com wrote: In binary search, mid = start + (end-start)/2 is used to avoid overflow, as said by a book. why can't we use mid = (start + end)/2, it says this statement may result in overflow ? * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286 * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Binary Search Problem
@Atul : got it. thanx :) * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286 * On Sun, Jan 8, 2012 at 3:27 AM, atul anand atul.87fri...@gmail.com wrote: @Sanjay: suppose Max_INT range is 300 now suppose end=300 and start =2 now using (start+end)/2 i.e *302*/2 but 302 goes out of range for and interger type as assumed... but if we use start + (end-start)/2 THEN 2 + (300-2)/2 , i.e 2+ *298*/2 here 298 300 hence it within int_Max range which was assumed 300.. On Sun, Jan 8, 2012 at 4:41 PM, Sanjay Rajpal sanjay.raj...@live.inwrote: actually book pages are images. My question is why second statement may result in overflow ? * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286, +91-9729683720 * On Sun, Jan 8, 2012 at 3:07 AM, saurabh singh saurab...@gmail.comwrote: not clear what you are trying to ask...can you quote exactly from the book? Saurabh Singh B.Tech (Computer Science) MNNIT blog:geekinessthecoolway.blogspot.com On Sun, Jan 8, 2012 at 4:34 PM, Sanjay Rajpal srn...@gmail.com wrote: In binary search, mid = start + (end-start)/2 is used to avoid overflow, as said by a book. why can't we use mid = (start + end)/2, it says this statement may result in overflow ? * Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India Contact: +91-8053566286 * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 use of fflush ?
After scanning the variable a, you will give a whitespace character(space,tab or newline), which will also get stored into stdin file. So next statement will scan this whitespace character. fflush(stdin) flushes(clears) the contents of stdin file, so this time scanf will not get whitespace character, instead it will get the character entered by user. or in second scanf statement, change it as scanf( %c,b), notice the space before %c. Correct me if m wrong :) Sanju :) On Sun, Oct 9, 2011 at 6:55 PM, rajul jain rajuljain...@gmail.com wrote: just take input a and b in one statement like this scanf(%d %d ,a ,b); On Sun, Oct 9, 2011 at 4:50 PM, Saravanan Selvamani saravananselvam...@gmail.com wrote: Hi, In the following programming when i gave character input rather than integer , the following scanf statement is not working . so i introduce the fflush(stdin) before the last scanf statement. But i get the same error as i before . #includestdio.h int main() { int a,b; scanf(%d,a); fflush(stdin); scanf(%d,b); printf(%d,b); //prints some garbage value. return 0; } so then what is the use of the fflush(stdin) and how to correct the above error? Thanks in advance. Regards P.S.Saravanan. -- why so serious? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 use of fflush ?
Sorry for previous email, did not read the question properly. Sanju :) On Sun, Oct 9, 2011 at 7:12 PM, Sanjay Rajpal srn...@gmail.com wrote: After scanning the variable a, you will give a whitespace character(space,tab or newline), which will also get stored into stdin file. So next statement will scan this whitespace character. fflush(stdin) flushes(clears) the contents of stdin file, so this time scanf will not get whitespace character, instead it will get the character entered by user. or in second scanf statement, change it as scanf( %c,b), notice the space before %c. Correct me if m wrong :) Sanju :) On Sun, Oct 9, 2011 at 6:55 PM, rajul jain rajuljain...@gmail.com wrote: just take input a and b in one statement like this scanf(%d %d ,a ,b); On Sun, Oct 9, 2011 at 4:50 PM, Saravanan Selvamani saravananselvam...@gmail.com wrote: Hi, In the following programming when i gave character input rather than integer , the following scanf statement is not working . so i introduce the fflush(stdin) before the last scanf statement. But i get the same error as i before . #includestdio.h int main() { int a,b; scanf(%d,a); fflush(stdin); scanf(%d,b); printf(%d,b); //prints some garbage value. return 0; } so then what is the use of the fflush(stdin) and how to correct the above error? Thanks in advance. Regards P.S.Saravanan. -- why so serious? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Attention All Members
This will reduce the no. of people coming to post on this group Sanju :) On Sat, Oct 8, 2011 at 2:33 PM, Ankur Garg ankurga...@gmail.com wrote: +1 On Sun, Oct 9, 2011 at 2:07 AM, Sunny sunny816.i...@gmail.com wrote: Now All of the messages are being Moderated and will be posted on the group only if they are found relevant, any irrelevant post be simply discarded without any notification till percentage of irrelevant posts reduces by a significant amount. if someone is found posting too many irrelevant post, he/she will be banned. Irrelevant Posts 1. Any Company Interview Question (Except Google, Facebook only) 2. Any Code Debugging Post (of type Plz Debug my code You should be able to do it yourself) 3. any kind of C/C++ output question. 4. Any Company related Queries 5. Any Book Requests 6. Any Post having No subjects. (if Subject are there they must be related and Give idea about the post. and again Don't post the complete Question in the subject. it should be posted in the body of the message) + Any OS compiler or other topics unless it requires some good Quality discussion. All the above types of post (Except 6) are now part of new group Interview Street (search Archives for the link). -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Re: MS Question - Median of a BST without using extra space and in O(n)
Recursion also requires space, so the problem is how to traverse without extra space. Once this is done, nothing is left in the problem. Sanju :) On Tue, Sep 27, 2011 at 8:35 AM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: @anshu can middle element can be found if the no. of nodes are not given... On Tue, Sep 27, 2011 at 8:34 PM, vikas vikas.rastogi2...@gmail.comwrote: a simple one is rabit-tortoise method, and using stackless traversal, facing a lot of corner cases in coding this, can someone check this as well? On Sep 27, 6:41 pm, anshu mishra anshumishra6...@gmail.com wrote: its not o(n) it is O(max height of tree) :P i have not seen the constraint. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Dheeraj Sharma* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 - Median of a BST without using extra space and in O(n)
Since we are given pointer to root node, we can easily find the minimum element in the tree. This will be the first node in the inorder traversal, now use method to find the inorder successor of a each node. Do it iteratively. Complexity will be O(n log n) and O(n) if tree is skewed. Correct me if m wrong. Sanju :) On Tue, Sep 27, 2011 at 8:49 AM, Nitin Garg nitin.garg.i...@gmail.comwrote: Do inorder traversal, to find out the total no. of nodes. Next time, do the inorder traversal but keeping the count of nodes visited and stop when you visit n/2 nodes. Non recursive In-order Traversal - *inorder*(node) *while* hasleftchild(node) *do* node = node.left *do* visit(node) *if* (hasrightchild(node)) *then* node = node.right *while* hasleftchild(node) *do* node = node.left *else* *while* node.parent ≠ *null* *and* node == node.parent.right *do* node = node.parent node = node.parent *while* node ≠ *null* Source: Wikipedia On Tue, Sep 27, 2011 at 9:13 PM, Sanjay Rajpal srn...@gmail.com wrote: Recursion also requires space, so the problem is how to traverse without extra space. Once this is done, nothing is left in the problem. Sanju :) On Tue, Sep 27, 2011 at 8:35 AM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: @anshu can middle element can be found if the no. of nodes are not given... On Tue, Sep 27, 2011 at 8:34 PM, vikas vikas.rastogi2...@gmail.comwrote: a simple one is rabit-tortoise method, and using stackless traversal, facing a lot of corner cases in coding this, can someone check this as well? On Sep 27, 6:41 pm, anshu mishra anshumishra6...@gmail.com wrote: its not o(n) it is O(max height of tree) :P i have not seen the constraint. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Dheeraj Sharma* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Nitin Garg Personality can open doors, but only Character can keep them open -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: output expalnation?
Compilation error. Definition of b is skipped by Switch statement. so 'b' not declared/defined error will occur. Correct me if m wrong. Sanju :) On Mon, Sep 26, 2011 at 6:38 PM, deepikaanand swinyanand...@gmail.comwrote: junk value cz b=6 will not get executed -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 : Non Decreasing Numbers
Can you plz tell the answer for for 3 answer=? nd for 4 answer=? Sanju :) On Sat, Sep 24, 2011 at 10:39 PM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: can u plz be more..clear ..with wat the input will consist of.. wat does this mean for 2 answer=55 does that mean..that how many non decreasing digits can be formed by 2 digit num On Sun, Sep 25, 2011 at 1:08 AM, shady sinv...@gmail.com wrote: A number is said to be made up of non-decreasing digits if all the digits to the left of any digit is less than or equal to that digit. for eg. 1122, 234, 2 , 0011 is a possible 4 digit non decreasing number so given a number n, how many n digit numbers exist ? for 2 answer = 55 Can someone post complexity and their 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. -- *Dheeraj Sharma* Comp Engg. NIT Kurukshetra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Amazon OS question
yah rite answer would be 5 and 4 resp. Sanju :) On Sat, Sep 24, 2011 at 10:04 PM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: 5 4? On Sun, Sep 25, 2011 at 9:33 AM, sivaviknesh s sivavikne...@gmail.comwrote: A parallel program consists of 8 tasks – T1 through T8. Each task requires one time step to be executed on a single processor. Let X - Y denote the fact that task X must be executed before task Y is executed. Suppose only the tasks X, Y are to be executed. On any multiprocessor machine it would require at least 2 time steps since in the first step X could be executed, and Y could be executed in the next time step (since it requires X to complete first). Now, suppose the following dependencies exist between the tasks T1 – T8: T1 - T2 T2 - T3 T3 - T6 T2 - T4 T4 - T7 T2 - T5 T5 - T8 What is the minimum number of time steps required to execute these 8 tasks on a 2 processor machine and a 4 processor machine? a)4 2 b)5 2 c)5 4 d)6 2 -- Regards, $iva -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Dheeraj Sharma* Comp Engg. NIT Kurukshetra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 : Non Decreasing Numbers
let the number of digits be n then answer would be ((n+9)! ) / (9! * n!) Sanju :) On Sat, Sep 24, 2011 at 11:51 PM, Yogesh Yadav medu...@gmail.com wrote: mistake in last post...it was not factorialsum upto n i.e =n(n+1)/2 i.e 10! is wrong ...it will be 10(10+1)/2 On Sun, Sep 25, 2011 at 12:14 PM, Yogesh Yadav medu...@gmail.comwrote: n=1 n=2 n=3 n=4 01010!(10!)! 1 9 9! (9!)! 2 8 8! 3 7 7! 4 6 6! 5 5 5! 6 4 4! 7 3 3! 8 2 2! 9 1 1! sum 10 55220 and so on On Sun, Sep 25, 2011 at 11:46 AM, Sanjay Rajpal srn...@gmail.com wrote: Can you plz tell the answer for for 3 answer=? nd for 4 answer=? Sanju :) On Sat, Sep 24, 2011 at 10:39 PM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: can u plz be more..clear ..with wat the input will consist of.. wat does this mean for 2 answer=55 does that mean..that how many non decreasing digits can be formed by 2 digit num On Sun, Sep 25, 2011 at 1:08 AM, shady sinv...@gmail.com wrote: A number is said to be made up of non-decreasing digits if all the digits to the left of any digit is less than or equal to that digit. for eg. 1122, 234, 2 , 0011 is a possible 4 digit non decreasing number so given a number n, how many n digit numbers exist ? for 2 answer = 55 Can someone post complexity and their 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. -- *Dheeraj Sharma* Comp Engg. NIT Kurukshetra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 : Non Decreasing Numbers
Or in other words... for n=2 , answer= (10*11)/2 for n=3, answer= (10*11*12)/(2*3) for n=4, answer = (10*11*12*13)/(2*3*4) Sanju :) On Sat, Sep 24, 2011 at 11:58 PM, Sanjay Rajpal srn...@gmail.com wrote: let the number of digits be n then answer would be ((n+9)! ) / (9! * n!) Sanju :) On Sat, Sep 24, 2011 at 11:51 PM, Yogesh Yadav medu...@gmail.com wrote: mistake in last post...it was not factorialsum upto n i.e =n(n+1)/2 i.e 10! is wrong ...it will be 10(10+1)/2 On Sun, Sep 25, 2011 at 12:14 PM, Yogesh Yadav medu...@gmail.comwrote: n=1 n=2 n=3 n=4 01010!(10!)! 1 9 9! (9!)! 2 8 8! 3 7 7! 4 6 6! 5 5 5! 6 4 4! 7 3 3! 8 2 2! 9 1 1! sum 10 55220 and so on On Sun, Sep 25, 2011 at 11:46 AM, Sanjay Rajpal srn...@gmail.comwrote: Can you plz tell the answer for for 3 answer=? nd for 4 answer=? Sanju :) On Sat, Sep 24, 2011 at 10:39 PM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: can u plz be more..clear ..with wat the input will consist of.. wat does this mean for 2 answer=55 does that mean..that how many non decreasing digits can be formed by 2 digit num On Sun, Sep 25, 2011 at 1:08 AM, shady sinv...@gmail.com wrote: A number is said to be made up of non-decreasing digits if all the digits to the left of any digit is less than or equal to that digit. for eg. 1122, 234, 2 , 0011 is a possible 4 digit non decreasing number so given a number n, how many n digit numbers exist ? for 2 answer = 55 Can someone post complexity and their 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. -- *Dheeraj Sharma* Comp Engg. NIT Kurukshetra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 IDC
Saurabh : Thank u very much :) Sanju :) On Thu, Sep 22, 2011 at 6:15 AM, saurabh sah.saurab...@gmail.com wrote: thanx to all @sanjay I have shared my interview experience at http://msidcinterview.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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 IDC
Hey saurabh, many many congratulations to u. Would u plz tell about the level of difficulty of questions asked in Interview round and also the kind of people they want ? Sanju :) On Wed, Sep 21, 2011 at 8:26 PM, saurabh sah.saurab...@gmail.com wrote: I sincerely thank this group as i got selected in MSIDC only because of this group . It was a wonderful experience for me at the interviews because the some of questions were closely related to the questions discussed here . And i also got to know about book Crackin the Coding Interviews which is more than sufficient for any company interviews . Finally i thank all those group members who shared their experiences and others who replied to their queries . GOOD LUCK to all Saurabh Sah Final Year, B.Tech MNIT JAIPUR -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] C Problem
#includestdio.h int main() { int a=5; printf(Size : %d\n,sizeof( a =15/2)); printf(A is %d.,a); } What will be the value of a now ? Plz explain. Sanju :) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] String
#includestdio.h #includestdlib.h #includestring.h void Swap(char *a,char *b) { char c; c=*a; *a=*b; *b=c; } int main() { char input[100]; printf(Enter a string (Length 100) : ); scanf(%[^\n],input); //Reversing the string int len=strlen(input); int i=0,j=len-1; while(i j) { Swap(input+i,input+j); i++; j--; } //Reversing the Words. i=0,j=0; while(input[j] != '\0') { if(input[j] == ' ') { int k= j-1; while(i k) { Swap(input+i,input+k); i++; k--; } i=++j; continue; } j++; } printf(%s,input); printf(\n\n); system(pause); } Sanju :) On Tue, Sep 13, 2011 at 2:35 AM, shashi kant shashiski...@gmail.com wrote: hey Karthik phodd diya yaar tune .tejas waale cha gaye On Tue, Sep 13, 2011 at 3:02 PM, kARTHIK R k4rth...@gmail.com wrote: Something like this. stackchar * S; void function(char *s) { char *ptr=s; while(*ptr++ !=' ') {} *ptr = '\0'; S.push(s); // Will push the string till NULL into the stack function(ptr+1); } // Pop from stack to get words Karthik R On Tue, Sep 13, 2011 at 2:50 PM, guna sekaran vgun...@gmail.com wrote: please write a code any one On Tue, Sep 13, 2011 at 2:06 PM, shady sinv...@gmail.com wrote: search archives, already done On Tue, Sep 13, 2011 at 1:39 PM, Anshul Khandelwal anshul.dans1...@gmail.com wrote: U can take command line argument in main main(int argc,char * argv[ ]) { for(i=argc-1,i=0;i--) printf(%s ,argv[i]); } On Tue, Sep 13, 2011 at 12:05 AM, hary rathor harry.rat...@gmail.com wrote: kapil : in your solution you are required extra O(n+n*sizeOf(int *)) both memory to create a link list that really costly -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 ANSHUL KHANDELWAL Final year Computer Engineering NIT Jaipur -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Shashi Kant * ***Think positive and find fuel in failure* *+917259733668 * *RD engineer , Tejas Networks Ltd Banglore. * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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]
A dynamic programming problem . Sanju :) On Tue, Sep 13, 2011 at 9:34 AM, prasanth n nprasnt...@gmail.com wrote: use dynamic programming.. On Sun, Sep 4, 2011 at 6:46 PM, aditya kumar aditya.kumar130...@gmail.com wrote: How to find longest common substring in two strings ? i want efficent code and iff possible any method other than using suffix tree . -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *prasanth* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] ASP problem
Post ur connection string here. Sanju :) On Mon, Sep 12, 2011 at 12:24 AM, himanshu kansal himanshukansal...@gmail.com wrote: I established a connection to a database in sql server 2008 through asp. the connection string is ok. i have checked it and even i have generated the connection from data link object and used that string but the error occurslogin failed for database pubs failed...unable to login i am using windows authentication mode. can this be a problem of database securitycan anybody tell me how to tackle with this problem.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Data Structures
Run-Time error for Segmentation Fault. Sanju :) On Mon, Sep 12, 2011 at 12:29 AM, Anshul Khandelwal anshul.dans1...@gmail.com wrote: @ teja bala - segmentation fault U hav to allocate memory for c and t pointers of node type. On Mon, Sep 12, 2011 at 12:29 PM, surender sanke surend...@gmail.comwrote: In c++, its assigning one object to other, its calling operator= default function, if u overload operator= it will call urs. it just assigns ur object contents coming from operator=() surender On Mon, Sep 12, 2011 at 12:07 PM, teja bala pawanjalsa.t...@gmail.comwrote: s typedef is der... On Mon, Sep 12, 2011 at 12:06 PM, sukran dhawan sukrandha...@gmail.comwrote: i think u missed a typedef b4... correct me if im wrong On Mon, Sep 12, 2011 at 11:10 AM, teja bala pawanjalsa.t...@gmail.com wrote: @sukran dis was asked in microsoft written ? take node *c 'll create a new node like that On Mon, Sep 12, 2011 at 11:00 AM, sukran dhawan sukrandha...@gmail.com wrote: pl tell me wat ur doin here... here u ve defined a variable node of type struct n. wat does the statement node *c ??? how can u create an instance of an instance ? On Mon, Sep 12, 2011 at 10:52 AM, teja bala pawanjalsa.t...@gmail.com wrote: struct n { int data; struct n* next}node; node *c,*t; c-data = 10; t-next = null; *c = *t; what is the effect of the last statement? Is dis correct? My Ans:- c 'll point to node t which contains garbage value in data fieldc and link field a null -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- ANSHUL KHANDELWAL B.TECH. Final year Computer Engineering Malaviya National Institute Of Technology, Jaipur -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Data Structures
Last Statement will perform bitwise copy of the operand on RHS in LHS. It is mereley an assignment, not changing pointers. For that u need double pointer here. Sanju :) On Mon, Sep 12, 2011 at 12:38 AM, Sanjay Rajpal srn...@gmail.com wrote: Run-Time error for Segmentation Fault. Sanju :) On Mon, Sep 12, 2011 at 12:29 AM, Anshul Khandelwal anshul.dans1...@gmail.com wrote: @ teja bala - segmentation fault U hav to allocate memory for c and t pointers of node type. On Mon, Sep 12, 2011 at 12:29 PM, surender sanke surend...@gmail.comwrote: In c++, its assigning one object to other, its calling operator= default function, if u overload operator= it will call urs. it just assigns ur object contents coming from operator=() surender On Mon, Sep 12, 2011 at 12:07 PM, teja bala pawanjalsa.t...@gmail.com wrote: s typedef is der... On Mon, Sep 12, 2011 at 12:06 PM, sukran dhawan sukrandha...@gmail.com wrote: i think u missed a typedef b4... correct me if im wrong On Mon, Sep 12, 2011 at 11:10 AM, teja bala pawanjalsa.t...@gmail.com wrote: @sukran dis was asked in microsoft written ? take node *c 'll create a new node like that On Mon, Sep 12, 2011 at 11:00 AM, sukran dhawan sukrandha...@gmail.com wrote: pl tell me wat ur doin here... here u ve defined a variable node of type struct n. wat does the statement node *c ??? how can u create an instance of an instance ? On Mon, Sep 12, 2011 at 10:52 AM, teja bala pawanjalsa.t...@gmail.com wrote: struct n { int data; struct n* next}node; node *c,*t; c-data = 10; t-next = null; *c = *t; what is the effect of the last statement? Is dis correct? My Ans:- c 'll point to node t which contains garbage value in data fieldc and link field a null -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- ANSHUL KHANDELWAL B.TECH. Final year Computer Engineering Malaviya National Institute Of Technology, Jaipur -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Book for C++
C++ Primer Plus by Stephen Prata. Sanju :) On Mon, Sep 12, 2011 at 1:15 AM, sukran dhawan sukrandha...@gmail.comwrote: Bjarne stroustroup On Mon, Sep 12, 2011 at 1:43 PM, Ankuj Gupta ankuj2...@gmail.com wrote: Hi Which is a good book for C++ ( Robert Lafore or Bjarne Stroustrup or Herbert Schildt) ? Ankuj -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] ASP problem
Apress Beginnin ASP.NET in C# 4.0. Sanju :) On Mon, Sep 12, 2011 at 3:40 AM, himanshu kansal himanshukansal...@gmail.com wrote: okk...i will post the connection string soonbut can anyone tell me the name of a good book on asp .net 3.5 for a newcomer. i am new to asp it would be very great if someone could also provide the link of the book here..' thanx in advance. On Mon, Sep 12, 2011 at 1:05 PM, Sanjay Rajpal srn...@gmail.com wrote: Post ur connection string here. Sanju :) On Mon, Sep 12, 2011 at 12:24 AM, himanshu kansal himanshukansal...@gmail.com wrote: I established a connection to a database in sql server 2008 through asp. the connection string is ok. i have checked it and even i have generated the connection from data link object and used that string but the error occurslogin failed for database pubs failed...unable to login i am using windows authentication mode. can this be a problem of database securitycan anybody tell me how to tackle with this problem.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 Himanshu Kansal Msc Comp. sc. (University of 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] ASP problem
Same is available in VB also. Sanju :) On Mon, Sep 12, 2011 at 3:46 AM, himanshu kansal himanshukansal...@gmail.com wrote: i have that book:P:P is there any other good book relating to VB. On Mon, Sep 12, 2011 at 4:15 PM, Sanjay Rajpal srn...@gmail.com wrote: Apress Beginnin ASP.NET http://asp.net/ in C# 4.0. Sanju :) On Mon, Sep 12, 2011 at 3:40 AM, himanshu kansal himanshukansal...@gmail.com wrote: okk...i will post the connection string soonbut can anyone tell me the name of a good book on asp .net 3.5 for a newcomer. i am new to asp it would be very great if someone could also provide the link of the book here..' thanx in advance. On Mon, Sep 12, 2011 at 1:05 PM, Sanjay Rajpal srn...@gmail.comwrote: Post ur connection string here. Sanju :) On Mon, Sep 12, 2011 at 12:24 AM, himanshu kansal himanshukansal...@gmail.com wrote: I established a connection to a database in sql server 2008 through asp. the connection string is ok. i have checked it and even i have generated the connection from data link object and used that string but the error occurslogin failed for database pubs failed...unable to login i am using windows authentication mode. can this be a problem of database securitycan anybody tell me how to tackle with this problem.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 Himanshu Kansal Msc Comp. sc. (University of 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 Himanshu Kansal Msc Comp. sc. (University of 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Pgm
Use Backtracking for this problem. Sanju :) On Sun, Sep 11, 2011 at 3:24 AM, parag khanna khanna.para...@gmail.comwrote: output : 1234 127 136 145 19 235 28 37 46 -- Parag Khanna B.tech Final Year NIT,Kurukshetra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 output .. help plz
+1 dave. Sanju :) On Tue, Sep 6, 2011 at 3:40 PM, Dave dave_and_da...@juno.com wrote: @Srivastav: Yeah. You need more parens: printf(%d,(int)(3.14*6.25*6.25)); Without the extra parens, the 3.14 is cast to an int, but then implicitly recast to a double for the multiplications. With the parens, the product is formed in type double, and then the result is cast into integer. Sorry for not recognizing the need before. Dave On Sep 6, 5:18 pm, UTKARSH SRIVASTAV usrivastav...@gmail.com wrote: printf behaves abnormally when it sees arguments not matching with its datatype @dave printf(%d,(int)3.14*6.25*6.25); is also giving 0. -- *UTKARSH SRIVASTAV CSE-3 B-Tech 3rd Year @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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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]
#include stdio.h #includeconio.h int main() { printf( %d,sizeof(main())); ... getche(); return 0; } o/p is 4..how ??? Sanju :) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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]
if main() were a pointer, then char c() { return '1'; } int main() { printf(%d,sizeof(c())); } would also have shown 4, but it shows 1. I think there is a hidden concept. If we change the return type of c() to void, it shows an error. But instead of c(), we use main() with void as return type, it shows 4. Whats happening here ? Sanju :) On Tue, Sep 6, 2011 at 10:51 AM, siddharam suresh siddharam@gmail.comwrote: *main()* is an address/probably the function pointer, Thank you, Sid. On Tue, Sep 6, 2011 at 11:19 PM, Sanjay Rajpal srn...@gmail.com wrote: #include stdio.h #includeconio.h int main() { printf( %d,sizeof(main())); ... getche(); return 0; } o/p is 4..how ??? Sanju :) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] explain the output..!!
Answers are : arr[i] : 1 arr[i] : 8 arr[i] : 64 arr[i] : 1000 Sanju :) On Mon, Sep 5, 2011 at 7:26 AM, sukran dhawan sukrandha...@gmail.comwrote: the answers are poy[i] = 1 pot[i] = 2 pot[i] = 8 pot[i] = 64 On Mon, Sep 5, 2011 at 7:55 PM, sukran dhawan sukrandha...@gmail.comwrote: well #define SIZEOF(arr) (sizeof(arr)/sizeof(arr[0])) gives the number of elements ie sizeof whole array /sizeof first element second macro #expr - prints variable name and if value is preceded is 0 it means it s in octal formt.it is printed in decimal format by conversion hope i am clear On Mon, Sep 5, 2011 at 7:48 PM, Mohit Goel mohitgoel291...@gmail.comwrote: 1) #include stdio.h #include stdlib.h #define SIZEOF(arr) (sizeof(arr)/sizeof(arr[0])) #define PrintInt(expr) printf(%s:%d\n,#expr,(expr)) int main () { /* The powers of 10 */ int pot[] = { 0001,0010,0100,1000 }; int i; for(i=0;iSIZEOF(pot);i++) PrintInt(pot[i]); return 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] explain the output..!!
Fourth number is not octal. Sanju :) On Mon, Sep 5, 2011 at 7:28 AM, Mohit Goel mohitgoel291...@gmail.comwrote: got it ..!! thnks everyone -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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
Will u plz elaborate more ? Sanju :) On Mon, Sep 5, 2011 at 8:44 AM, Neha Singh neha.ndelhi.1...@gmail.comwrote: You are given a date in the format DD/MM/ You have to convert to it to the nearest palindromic date. Write a function to do the above task ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] DE shaw question- urgent
I think when we have to create a singleton class, we can use private constructor. Objects of such classes can be constructed using static functions that can be accessed using class name and scope resolution operators. This is useful because user can create only one object of that class, which is sometimes required. other case might be using static functions, but return a new object each time. We can also keep a limit on the no. of objects that can be created for a class. Sanju :) On Mon, Sep 5, 2011 at 9:06 AM, Neha Singh neha.ndelhi.1...@gmail.comwrote: When do u hv a private constructor for a class ??? How to create an object of such a class ?? What's its utility ?? Anyone plz explain asap?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] explain the output..!!
Oh , yes it will print pot[i]. Sanju :) On Mon, Sep 5, 2011 at 7:57 AM, SANDEEP CHUGH sandeep.aa...@gmail.comwrote: @sanjay :it will not print arr[i] , it will print pot[i] On Mon, Sep 5, 2011 at 8:13 PM, rajul jain rajuljain...@gmail.com wrote: good question yaar ,from which book you read this. On Mon, Sep 5, 2011 at 7:59 PM, Sanjay Rajpal srn...@gmail.com wrote: Fourth number is not octal. Sanju :) On Mon, Sep 5, 2011 at 7:28 AM, Mohit Goel mohitgoel291...@gmail.comwrote: got it ..!! thnks everyone -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] determine error..!!
In the max function, return statement can't be present as an expression in ternary conditional operator. it should be like return x y ? x ; y; In the second question, p is a pointer to a pointer to a const char, but argv is a pointer to a pointer to a char. The difference lies in the type of operand to which argv and p point. On 9/5/11, Mohit Goel mohitgoel291...@gmail.com wrote: 1) #include stdio.h #define PrintInt(expr) printf(%s : %d\n,#expr,(expr)) int max(int x, int y) { (x y) ? return x : return y; } int main () { int a = 10, b = 20; PrintInt(a); PrintInt(b); PrintInt(max(a,b)); } 2#include stdio.h void foo(const char **p) { } int main (int argc, char **argv) { foo(argv); return 0; } i think sending a normal pointer to a function requiring const pointer does not give any warning..but it still giving an error -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Sanju :) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Request for crack coding book ebook
Send it to me also. Thanx in advance .. :) Sanju :) On Sat, Sep 3, 2011 at 9:58 AM, UMESH KUMAR kumar.umesh...@gmail.comwrote: hi anybody do you have CrackCoding ebook pls send . thanks -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] SEEK advice very urgent
I think u should go and have experience in latest technologies, after all Japan is known for new technologies. You will get many things to learn there. Sanju :) On Thu, Sep 1, 2011 at 12:39 AM, vaibhav shukla vaibhav200...@gmail.comwrote: if there is no bond then u must go... after all its money and technology for which japan is good.. gud luck On Thu, Sep 1, 2011 at 12:39 PM, rahul sharma rahul23111...@gmail.comwrote: salary is good...u can gobe with in technology with japannn..gud luck On Thu, Sep 1, 2011 at 12:37 PM, raj kumar megamonste...@gmail.comwrote: Hi friends, I have cleared the prior examination of Works application a japenese company which is offering a package of $7pannum in tokyo ,ther's high probability of getting selected in interview but as i hav read tha cost of living in tokyo is too high plus japan is not that much good for indians as US.So please give your valuable advice what should i do take this offer or reject by remainig silent in the interview, also if this company selects me i will not be able to sit in any ohter company bcoz of the placement policies of my college , please help ... if you have any relative in japan kindly ask them please thanks -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- best wishes!! Vaibhav -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 error???
@Rahul : I have also mentioned that for the linker error. You can place a definition int var; after main(), it will work. Sanju :) On Wed, Aug 31, 2011 at 11:14 AM, rahul vatsa vatsa.ra...@gmail.com wrote: @sanju, if u declare a variable with extern, at compile time its defn is nt looked for, rather @ link time corresponding defn is looked for by the linker. nd if the defn is nt ther, it will raise a linker error, as in case of this prog @rahul, ya off course, for a variable to be global it hs to be defined at file scope. On Wed, Aug 31, 2011 at 11:29 AM, Sanjay Rajpal srn...@gmail.com wrote: Linker error, failed to find symbol 'var'. Sanju :) On Wed, Aug 31, 2011 at 8:25 AM, rahul sharma rahul23111...@gmail.comwrote: but it is defined inside mainu mean to say for varibale to be gloabal it must be defines outsyd all fxns?? On Wed, Aug 31, 2011 at 8:35 PM, Ashima . ashima.b...@gmail.com wrote: u hv just declared the variable and not defined it.So no memory is allocated to var. so u l get the undefined reference error. either remove extern or define new local variable int var =10; Ashima M.Sc.(Tech)Information Systems 4th year BITS Pilani Rajasthan On Wed, Aug 31, 2011 at 7:56 AM, Rajesh Kumar testalgori...@gmail.comwrote: What we do to remove error?? #includestdio.h extern int var; main() { var=10; return 0; } Regards Rajesh Kumar -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] c doubt
The result will depend on alignment : byte alignment or Word alignment. Sanju :) On Wed, Aug 31, 2011 at 2:51 AM, PRATEEK VERMA prateek...@gmail.com wrote: oh i'm sorry guys galz,its my mistake..actually i forgot to add one more field in struct this is the correct one typedef struct { int bit1:29; int bit2:4; }bit; int main() { printf(%d\n,sizeof(bit)); return 0; } now what will be the output...i'm sure you will amazed to see the result after changing bitfield of bit1 to 28. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 error???
Linker error, failed to find symbol 'var'. Sanju :) On Wed, Aug 31, 2011 at 8:25 AM, rahul sharma rahul23111...@gmail.comwrote: but it is defined inside mainu mean to say for varibale to be gloabal it must be defines outsyd all fxns?? On Wed, Aug 31, 2011 at 8:35 PM, Ashima . ashima.b...@gmail.com wrote: u hv just declared the variable and not defined it.So no memory is allocated to var. so u l get the undefined reference error. either remove extern or define new local variable int var =10; Ashima M.Sc.(Tech)Information Systems 4th year BITS Pilani Rajasthan On Wed, Aug 31, 2011 at 7:56 AM, Rajesh Kumar testalgori...@gmail.comwrote: What we do to remove error?? #includestdio.h extern int var; main() { var=10; return 0; } Regards Rajesh Kumar -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: memory allocation
new/malloc/calloc : Heap Memory. Sanju :) On Wed, Aug 31, 2011 at 7:00 AM, Abhishek Mallick abhishek.mallick2...@gmail.com wrote: heap memory is allocated using new/malloc. memory from stack is allocated for local variables/objects for a function. Correct me if I am wrong. On Aug 31, 6:37 pm, ravi maggon maggonr...@gmail.com wrote: What memory is allocated to a function, to a variable, to a object created at run time using new or malloc and to a function containing a object with run time memory allocation. -- Regards Ravi Maggon Final Year, B.E. CSE Thapar University -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Static variable
Static variables are always stored in the data section. Sanju :) On Wed, Aug 31, 2011 at 9:04 AM, Swathi chukka.swa...@gmail.com wrote: C standard doesn't define where static variables has to be stored. All it says is to persist the data across the multiple function calls. So I think the answer varies based on the compiler implementation but printing all zeros makes more logical. On Wed, Aug 31, 2011 at 9:25 PM, rohit raman.u...@gmail.com wrote: +1 to chris -- 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/-/fzTBEIWLGcAJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Two Pointers Missing
Is it given that first left pointer is missing and there after right pointer is missing ? Or first right pointer may also be missing ? Sanju :) On Wed, Aug 31, 2011 at 9:23 AM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: A doubly linked list has one Left pointer missing and at some point..one Right pointer missing..how to repair the doubly linked list? ? -- *Dheeraj Sharma* Comp Engg. NIT Kurukshetra +91 8950264227 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Static variable
Thank u swathi for making me clear about static variables. Sanju :) On Wed, Aug 31, 2011 at 9:10 AM, Swathi chukka.swa...@gmail.com wrote: Google it.. you will find the answer, http://www.velocityreviews.com/forums/t443436-where-is-a-static-variable-stored.html On Wed, Aug 31, 2011 at 9:35 PM, Sanjay Rajpal srn...@gmail.com wrote: Static variables are always stored in the data section. Sanju :) On Wed, Aug 31, 2011 at 9:04 AM, Swathi chukka.swa...@gmail.com wrote: C standard doesn't define where static variables has to be stored. All it says is to persist the data across the multiple function calls. So I think the answer varies based on the compiler implementation but printing all zeros makes more logical. On Wed, Aug 31, 2011 at 9:25 PM, rohit raman.u...@gmail.com wrote: +1 to chris -- 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/-/fzTBEIWLGcAJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Two Pointers Missing
What we are given about the Linked List, pointer to start or to the end ? Sanju :) On Wed, Aug 31, 2011 at 9:37 AM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: no no.. First right pointer is missing then after few nodes..left pointer is missing On Wed, Aug 31, 2011 at 9:57 PM, Sanjay Rajpal srn...@gmail.com wrote: Is it given that first left pointer is missing and there after right pointer is missing ? Or first right pointer may also be missing ? Sanju :) On Wed, Aug 31, 2011 at 9:23 AM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: A doubly linked list has one Left pointer missing and at some point..one Right pointer missing..how to repair the doubly linked list? ? -- *Dheeraj Sharma* Comp Engg. NIT Kurukshetra +91 8950264227 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- *Dheeraj Sharma* Comp Engg. NIT Kurukshetra +91 8950264227 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Two Pointers Missing
Chris : he said first, right pointer is missing, how can u repair that left pointer first as you can't go forward ? Sanju :) On Wed, Aug 31, 2011 at 9:39 AM, Chris lokr...@gmail.com wrote: When you say missing, I assume the left or right pointer is null. If that's the case, this could be a possible solution: // this fixes the missing left pointers traversing from the head node* curr = head; while (curr-right != null ) { if (curr-right-left == null) { curr-right-left = curr; } curr = curr-right; } // reverse the logic to fix pointers in the other direction starting at the end of the list node* curr = tail; while (curr-left != null) { if (curr-left-right == null) { curr-left-right = curr; } curr = curr-left; } On Aug 31, 10:23 am, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: A doubly linked list has one Left pointer missing and at some point..one Right pointer missing..how to repair the doubly linked list? ? -- *Dheeraj Sharma* Comp Engg. NIT Kurukshetra +91 8950264227 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] print level by level withoust recursion
We can use concept of threaded binary tree, bu we'll have to store a pointer to LEVEL Order Successor of each node. So the problem is reduced to find the level order successor of a node. Sanju :) On Wed, Aug 31, 2011 at 9:52 AM, manish kapur manishkapur.n...@gmail.comwrote: i think hint is mentioned in the ques..there is an extra pointer..u can take it as parent pointer.. On Wed, Aug 31, 2011 at 10:13 PM, Abhishek Yadav algowithabhis...@gmail.com wrote: can we use loops or GOTO statements On Wed, Aug 31, 2011 at 10:03 PM, manish kapur manishkapur.n...@gmail.com wrote: Given a binary Tree and a node pointer extra in a tree. print all the node level by level. You cannot use any Stack ,recursion and queue. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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
I think this code is perfect. Sanju :) On Thu, Sep 1, 2011 at 6:54 AM, Piyush Grover piyush4u.iit...@gmail.comwrote: What's wrong with this?? for( i = 0 ; i n ; ++i ) for( j = 0 ; j m ; ++j ) if( a[i][j] != 0 ) a[i][0] = a[0][j] = 1; for( i = 0 ; i n ; ++i ) for( j = 0 ; j m ; ++j ) if( a[i][0] + a[0][j] != 0 ) a[i][j] = 1; On Thu, Sep 1, 2011 at 5:45 AM, Dave dave_and_da...@juno.com wrote: @Replying to my own posting: Propagating a[0][0] as in my most recent post isn't correct. Gene is correct to have two flags that indicate whether the first row and/or the first column are to be filled with 1s. Dave On Aug 31, 7:01 pm, Dave dave_and_da...@juno.com wrote: @Icy: I forgot about a[0][0]. So I need to add a few lines at the end of my code, so that it becomes: for( i = 1 ; i n ; ++i ) for( j = 1 ; j m ; ++j ) if( a[i][j] != 0 ) a[i][0] = a[0][j] = 1; for( i = 1 ; i n ; ++i ) for( j = 1 ; j m ; ++j ) if( a[i][0] + a[0][j] != 0 ) a[i][j] = 1; // the following added to propogate a[0][0], if necessary. if( a[0][0] != 0 ) { for( i = 1 ; i n ; ++i ) a[i][0] = 1; for( j = 1 ; j m ; ++j ) a[0][j] = 1; } Dave On Aug 31, 5:12 pm, icy` vipe...@gmail.com wrote: Dave has a nice idea but I cant get it to work =/ [[1, 0, 0, 1], [0, 0, 1, 0], [0, 0, 0, 0]] original matrix [[1, 0, 1, 1], [1, 1, 1, 1], [0, 0, 1, 1]] dave's [[1, 1, 1, 1], [1, 1, 1, 1], [1, 0, 1, 1]] expected Maybe I converted it wrong. My method was basically the same as Anup's -- 1st pass fill rows and convert 1's to 2's. 2nd pass check for 2's and fill those columns. But complexity seems to be n*m*m + n*m*n = nm^2 + mn^2 which is about O(n^2 m^2) ?=/ I would like to get Dave's to work =P On Aug 31, 1:47 pm, siva viknesh sivavikne...@gmail.com wrote: @dave...additionally u ve to do this...checking the 1st row nd 1st column... if(a[0][0]) set both first row and first column; else for(i=1;in;i++) if(a[0][i]) set first row; else set first column; On Aug 31, 10:34 pm, siva viknesh sivavikne...@gmail.com wrote: dave s algo is nice :) On Aug 31, 10:09 pm, Dave dave_and_da...@juno.com wrote: @Ashima: Scan all but the first row and the first column. If there is a 1 in a row, set the first element of that row to 1. If there is a 1 in a column, set the first element of that column to zero. Now, set any element in all but the first row and the first column of the matrix that has a 1 it the first element of its row or a 1 in its first element of its colunn to 1. Dave On Aug 31, 12:02 pm, Ashima . ashima.b...@gmail.com wrote: @dave wats d logic behind ur code Ashima M.Sc.(Tech)Information Systems 4th year BITS Pilani Rajasthan On Wed, Aug 31, 2011 at 9:05 AM, Dave dave_and_da...@juno.com wrote: @Manish: for( i = 1 ; i n ; ++i ) for( j = 1 ; j m ; ++j ) if( a[i][j] != 0 ) a[i][0] = a[0][j] = 1; for( i = 1 ; i n ; ++i ) for( j = 1 ; j m ; ++j ) if( a[i][0] + a[0][j] != 0 ) a[i][j] = 1; Dave On Aug 31, 8:40 am, manish kapur manishkapur.n...@gmail.com wrote: Input is a matrix of size n x m of 0s and 1s. eg: 1 0 0 1 0 0 1 0 0 0 0 0 If a location has 1; make all the elements of that row and column = 1. eg 1 1 1 1 1 1 1 1 1 0 1 1 Solution should be with Time complexity = O(n*m) and O(1) extra space -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.-Hidequotedtext- - Show quoted text -- Hide quoted text - - Show quoted text -- 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
Re: [algogeeks] Let's see if U can find the bug...
This program is working fine. No bugs. Sanju :) On Mon, Aug 29, 2011 at 11:06 PM, Mohit Gupta mohitgupta.n...@gmail.comwrote: *1.* /* Print armstrong numbers from 1 to 500 */ /*1st version of prgrm: I am using pow function*/ #includestdio.h #includeconio.h #includemath.h int main() { int num=1,temp,sum,r; while(num=500){ sum=0; temp=num; while(temp){ r=temp%10; sum+=pow(r,3); temp/=10; } if(sum==num) printf(%d\n,num); num++; } getch(); return 0; } It prints : 1 370 371 407 But it does not print 153 which is also armstrong number. WHY??? BUT if I change: pow(r,3) to r*r*r in codethen it prints: 1 153 370 371 407 WHY 153 was not printed if i use pow() function??? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Find square root a number
Binary Search kind of mathod is useful here : float SquareRoot(float n,float start,float end) { float s=(start+end)/2; if(n - sqr(s) 0.001) (n - sqr(s) -0.001)) return (end+start)/2; else if(sqr(s) n) return SquareRoot(n,0.0,s); else return SquareRoot(n,s,end); } Sanju :) On Tue, Aug 30, 2011 at 3:25 AM, UTKARSH SRIVASTAV usrivastav...@gmail.comwrote: i don't whethe you have studied a subject cbnst from that use newton raphson method On Tue, Aug 30, 2011 at 2:39 AM, Ankuj Gupta ankuj2...@gmail.com wrote: U can use binary search method On Aug 30, 1:56 pm, Rajeev Kumar rajeevprasa...@gmail.com wrote: use Babylonian method(Efficient) algrithm.. Refer : http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylo... public *void* getSquareRoot(double s) { double Xn = 2.0; double lastXn = 0.0; while (Xn != lastXn) { lastXn = Xn; Xn = (Xn + s / Xn) / 2.0; } return Xn; } On Tue, Aug 30, 2011 at 1:49 PM, Ankur Garg ankurga...@gmail.com wrote: @techcoder Making an array of 32768 or INT_MAX will make ur compiler cry Also ur case doesnt handle the scenario where square root is a decimal number On Tue, Aug 30, 2011 at 1:35 PM, tech coder techcoderonw...@gmail.comwrote: the sqrt of 32 bit number can't be more than 16 bits. have an array of 2^16 elemnts wtih elemts 1 2 3 4 5 32768 . now apply binary search i=a[mid]where mid=(lower+upper)/2 if(i*i==num) i is the sqrt increment lower and upper accordingly as we do in binary search so order is Olognwhere n=2^16 On Tue, Aug 30, 2011 at 11:37 AM, Raghavan its...@gmail.com wrote: how to design this logic effectively? double squareRoot(int num){ } -- Thanks and Regards, Raghavan KL -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Thank You Rajeev Kumar -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *UTKARSH SRIVASTAV CSE-3 B-Tech 3rd Year @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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Help ! - Explain Sscanf
only year gets scanned here, * suppresses assignment of day and month. Sanju :) On Tue, Aug 30, 2011 at 9:08 AM, sukran dhawan sukrandha...@gmail.comwrote: sscanf is similar to scanf except that input is read from string rather than keyboard or i/o *c -supression character.it reads character and discards it.doesnt store it anywhere On Tue, Aug 30, 2011 at 9:32 PM, Mani Bharathi manibharat...@gmail.comwrote: char*str=11/1/1999; sscanf(str,*c*cd,month,day,year); -- 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/-/60kR7ykKiksJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Help ! - Explain Sscanf
yes % has to be there. Sanju :) On Tue, Aug 30, 2011 at 11:12 AM, sukran dhawan sukrandha...@gmail.comwrote: yes conversion specifier missing i think On Tue, Aug 30, 2011 at 11:37 PM, SANDEEP CHUGH sandeep.aa...@gmail.comwrote: but sanjay in the ques it is *c*cd shudn't there be a % before that ?? On Tue, Aug 30, 2011 at 11:22 PM, Sanjay Rajpal srn...@gmail.com wrote: Run the following program : main() { int a,b; scanf(%d %*d,a,b); printf(\na= %d, b=%d,a,b); } now see the values of a and b, and post the result here. Sanju :) On Tue, Aug 30, 2011 at 10:46 AM, sukran dhawan sukrandha...@gmail.comwrote: i don think so.can u brief it ? On Tue, Aug 30, 2011 at 10:45 PM, Sanjay Rajpal srn...@gmail.comwrote: only year gets scanned here, * suppresses assignment of day and month. Sanju :) On Tue, Aug 30, 2011 at 9:08 AM, sukran dhawan sukrandha...@gmail.com wrote: sscanf is similar to scanf except that input is read from string rather than keyboard or i/o *c -supression character.it reads character and discards it.doesnt store it anywhere On Tue, Aug 30, 2011 at 9:32 PM, Mani Bharathi manibharat...@gmail.com wrote: char*str=11/1/1999; sscanf(str,*c*cd,month,day,year); -- 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/-/60kR7ykKiksJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Explanation
Why in the first case f(1,2) is evaluated first ? Any plausible explanation for that ? Sanju :) On Mon, Aug 29, 2011 at 12:50 AM, Vrashabh Irde vrashab...@gmail.comwrote: Hi, See Question 11.17 of C FAQ . http://c-faq.com/ansi/stringize.html In the first case f(1,2) happens first and in the second case g(X) happens first and then f(1,2) Hence in the first case - h(f(1,2,)) = h(12) = 12 and second case = g(f(1,2)) = f(1,2) In other words Case1: - Expanding macro h: - a = f(1,2) - Expanding macro f: - a##b = 12 = 12 = g(12) - Expanding macro g: - #a is replaced by a string: #a = 12 O/P = 12 Case 2: - Expanding macro g: - #a = f(1,2) O/P = f(1,2) Macros are evil. Regards, Vrashabh Irde On Mon, Aug 29, 2011 at 1:06 PM, Sahil Garg garg.sahi...@gmail.com wrote: Plz explain the solution.. Acc to me it should be.. 12 12 On 8/29/11, PRATEEK VERMA prateek...@gmail.com wrote: #define g(a) #a replaces any occurrence of g(a) with string a. #define f(a,b) a##b replaces any occurrence of f(a,b) with concatenation of a and b -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Sent from my mobile device Sahil Garg Computer Engg. DCE -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Explanation
Utkarsh : according to you, in second printf also, f(1,2) has to be expanded first since its value is taken by g ? Sanju :) On Mon, Aug 29, 2011 at 1:53 AM, UTKARSH SRIVASTAV usrivastav...@gmail.comwrote: it is evaluated first because it's value is taken by the h function -- *UTKARSH SRIVASTAV CSE-3 B-Tech 3rd Year @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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Probability
It should be 1 - no one hits, i.e. 1 - 0.3*0.6*0.5*0.6 = 1 - 0.0540=0.9460. Correct me if m wrong.. Sanju :) On Mon, Aug 29, 2011 at 5:19 AM, Abhishek Yadav algowithabhis...@gmail.comwrote: i guess it would be 0.7 + 0.3*0.6 + 0.3*0.4*0.5 + 0.3*0.4*0.5*0.4 =.964.correct me if i am wrong.?? On Mon, Aug 29, 2011 at 5:34 PM, Naman Mahor naman.ma...@gmail.comwrote: An anti aircraft gun can fire four shots at a time. If the probabilities of the first, second, third and the last shot hitting the enemy aircraft are 0.7, 0.6, 0.5 and 0.4, what is the probability that four shots aimed at an enemy aircraft will bring the aircraft down? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Re: How to save a binary search tree space efficiently
Does ur tree has parent pointer ? Sanju :) On Sun, Aug 28, 2011 at 1:09 AM, Navneet navneetn...@gmail.com wrote: Store any two traversals (inorder must) and reconstruct it later. Total space 2n (n = number of nodes) On Aug 28, 11:29 am, rohit rajuljain...@gmail.com wrote: How to save a binary search tree space efficiently and built it again , just tell any idea. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Que of Tejas Network
This is a classic dynamic problem. Search it on www.geeksforgeeks.org for Finding Largest Non-Contiguous Sum in an array. Sanju :) On Sun, Aug 28, 2011 at 6:21 AM, Kamakshii Aggarwal kamakshi...@gmail.comwrote: let arr[] stores the value of max amount upto each shop that they can rob. arr[1]=x[1]; arr[2]=x[2]; for(i=3;i=n;i++) { arr[i]=max{(arr[i-2]+x[i]),arr[i-1]}; } arr[n] gives the max amount that can be robbed... correct me if i am wrong. @prag:has tejas networks visited ur campus? On Sun, Aug 28, 2011 at 6:34 PM, Prags onlypr...@gmail.com wrote: Q- There are n consecutive shops. two mafias plan to rob the shops. Each shop has cash in their locker. there is one restriction that they cannot rob any consecutive shop. write a program that will maximize their profit. cash in the shops were given in x[i] i=1... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Print tree like a tree
It is basically BFS for this tree, just maintain spaces at each level provided tree is a complete binary tree. Sanju :) On Sun, Aug 28, 2011 at 7:46 AM, Navneet Gupta navneetn...@gmail.comwrote: Hope the question is clear. Basically you need to print a given tree such that spaces will depict the left/right relation at every level. output should be something like a b c d e f g Levels are separated by new lines. Notice that space between nodes at higher levels increases with the number of levels we have. Assume a max of 10 levels. But the algorithm should scale. -- 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Print tree like a tree
how will u then take care of spaces ? Sanju :) On Sun, Aug 28, 2011 at 8:18 AM, Navneet navneetn...@gmail.com wrote: I should mention it's a binary tree, not necessarily complete. Though, i don't think BFS search has anything to do with tree being complete. Child's position will be calculated from parent positions. leftchildX = parentX - value(based on level) rightchildY = parentY + value(based on level) On Aug 28, 7:57 pm, Sanjay Rajpal srn...@gmail.com wrote: It is basically BFS for this tree, just maintain spaces at each level provided tree is a complete binary tree. Sanju :) On Sun, Aug 28, 2011 at 7:46 AM, Navneet Gupta navneetn...@gmail.com wrote: Hope the question is clear. Basically you need to print a given tree such that spaces will depict the left/right relation at every level. output should be something like a b c d e f g Levels are separated by new lines. Notice that space between nodes at higher levels increases with the number of levels we have. Assume a max of 10 levels. But the algorithm should scale. -- 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Adding Two no without using any operator...??
But it works only for +ve numbers. Sanju :) On Sun, Aug 28, 2011 at 9:57 AM, Abhishek Yadav algowithabhis...@gmail.comwrote: Very nice solution sourabh. On Sun, Aug 28, 2011 at 9:52 PM, Dave dave_and_da...@juno.com wrote: @Shravanthi: Write a and b in binary, and then apply the bitwise exclusive-or to them and you will see why. Dave On Aug 28, 9:24 am, Shravanthi U M shravanthium...@gmail.com wrote: if we give a=10, b=5 we get a^b=15 but wen a=10,b=7 we get a^b=13 why s it so,..??? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Explanation
#include stdio.h #define f(a,b) a##b #define g(a) #a #define h(a) g(a) int main() { printf(%s\n,h(f(1,2))); printf(%s\n,g(f(1,2))); return 0; } o/p : 12 f(1,2) friends, a valid explanation is required. Sanju :) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 program explain
It is checking the MSB of the integer and, it is 1(checked by Bitwise AND with 1 at MSB), it prints 1 else 0. Sanju :) On Sat, Aug 27, 2011 at 9:25 PM, rohit rajuljain...@gmail.com wrote: how is this program convert number to binary equivalent int main() { unsigned int num =23 ; int i; for(i=0;i16;i++) printf(%d\n,(numi115)?1:0); } please explain -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: inorder predecessor
Vikram : will u plz elaborate more on ur solution ? Sanju :) On Fri, Aug 26, 2011 at 5:24 AM, Vikram Singh singhvikram...@gmail.comwrote: ya thats one option but that gives ans in O(n), requires additional memory... and unnecessarily finds for all which is not required... my sol doesnt require any extra space i.e. in O(1) space... and also in O(log n) time... tell if dere is any missing case On Aug 26, 4:58 pm, sukran dhawan sukrandha...@gmail.com wrote: is it not possible to traverse tree in order and store in array. then figure out the element and print the previous element? On Fri, Aug 26, 2011 at 2:04 PM, Vikram Singh singhvikram...@gmail.com wrote: i figured out algo to find the inorder predecessor of a bst without using parent pointer... just wanna confirm if its missing any case if the left child(subtree) of node exist, then predecessor ll be the max value in the left subtree. else predecessor ll be one of the ancestor in this case, starting from the given node, we hv to find a closest ancestrous node which is right child of its parent... the parent ll be the predecessor... and i made the parent implementation without changing the structure of the node... using while loop... let me know if i m missing ant case... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Re: inorder predecessor
got it Vikram :) Sanju :) On Fri, Aug 26, 2011 at 5:43 AM, Vikram Singh singhvikram...@gmail.comwrote: i m writing just a pseudocode... // root is the root of treeand node is the node whose predecessor is to be found predecessor(root, node) { parent=NULL; if(root==NULL) return ; if(node-left!=NULL) { // find max value in left subtree... } else { while(root!=NULL root-data!=node-data) { if(root-data node-data) { root=root-left; } else if(root-data node-data) { parent=root; root=root-right; } } return parent; } } i hope it makes u understand@sanjay... On Aug 26, 5:27 pm, Sanjay Rajpal srn...@gmail.com wrote: Vikram : will u plz elaborate more on ur solution ? Sanju :) On Fri, Aug 26, 2011 at 5:24 AM, Vikram Singh singhvikram...@gmail.com wrote: ya thats one option but that gives ans in O(n), requires additional memory... and unnecessarily finds for all which is not required... my sol doesnt require any extra space i.e. in O(1) space... and also in O(log n) time... tell if dere is any missing case On Aug 26, 4:58 pm, sukran dhawan sukrandha...@gmail.com wrote: is it not possible to traverse tree in order and store in array. then figure out the element and print the previous element? On Fri, Aug 26, 2011 at 2:04 PM, Vikram Singh singhvikram...@gmail.com wrote: i figured out algo to find the inorder predecessor of a bst without using parent pointer... just wanna confirm if its missing any case if the left child(subtree) of node exist, then predecessor ll be the max value in the left subtree. else predecessor ll be one of the ancestor in this case, starting from the given node, we hv to find a closest ancestrous node which is right child of its parent... the parent ll be the predecessor... and i made the parent implementation without changing the structure of the node... using while loop... let me know if i m missing ant case... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: unsorted array problem
XOR all the elements in the array, the result will be the XOR of the two numbers occuring odd number of times. Now take any set bit of th result(u can determine the position of any bit set in the number). Divide the array such that for the numbers for which at this location(where the bit is set in the result) is set and those where this bit is not set. now XOR both the sets, this will give u two numbers,one from each of the two subsets. Sanju :) On Fri, Aug 26, 2011 at 10:49 AM, Don dondod...@gmail.com wrote: I believe this is what techcoder is saying: int a[N]; // Find the bitwise xor of all the array values. // These are the bits which are different between the two results. int xor = 0; for(i = 0; i N; ++i) xor ^= a[N]; // Find the low order bit of xor int bit = 1; while(!(xor bit)) bit = 1; // xor the values with bit set to get one result // xor the values with bit unset to get the other result int result1 = 0, result2 = 0; for(i = 0; i n; ++i) { if (a[i] bit) result1 ^= a[i]; else result2 ^= a[i]; } Now result1 result2 are the values which appear an odd number of times. It is O(n). Don On Aug 26, 12:13 pm, Dave dave_and_da...@juno.com wrote: @Tech: I'm not sure I understand your algorithm. Let's try it on {1,1,2,2,3,4,5,5,6,6,7,7}. The two number occurring an odd number of times are 3 and 4. We xor the numbers getting 7 = 111 in binary. Now how do we divide the numbers into two groups? Dave On Aug 26, 11:09 am, tech coder techcoderonw...@gmail.com wrote: it can be done in O(N) by using XOR ing the elements 1: Xor all the elemnts since those elemnts that even freq will nullify each other we get number taht will tell in which the two required number differ. 2: divide the array in two sets on the basis of bit in which numbers differ 3:1 element will be in one set another will be in another set 4: XOR both the sets again we get both the elemts On Thu, Aug 25, 2011 at 12:50 PM, Umesh Jayas algowithum...@gmail.com wrote: int main() { int arr[]={1,2,5,1,5,1,1,3,2,2,}; int elements = sizeof(arr)/sizeof(arr[0]); int count=1; int num; sort(arr,arr+elements); num=arr[0]; for(int i=1;ielements;i++) { if(arr[i]==num) count++; else { if(count%2==0) { num=arr[i]; count=1;} else {cout\narr[i-1]; count=1; num=arr[i]; } } } getch(); } complexity: O(nlogn) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] apti!
20 men ? (x-10)20=10x Sanju :) On Fri, Aug 26, 2011 at 11:17 AM, gmagog...@gmail.com gmagog...@gmail.comwrote: 20? Yanan Cao On Fri, Aug 26, 2011 at 1:12 PM, priya ramesh love.for.programm...@gmail.com wrote: A certain number of men can finish a piece of work in 10 days. If however there were 10 men less it will take 10 days more for the work to be finished. How many men were there originally? (a) 110 men (b) 130 men (c) 100 men (d) none of these -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] apti!
Sry for prrevious post . It is question of R S Aggarwal, and solved using conecpt of direct and indirect proportions. Originally,let there be x men. Less men,more days(indirect proposition) (x-10) : x :: 100 : 110 (x-10) * 110 = x * 100 ANS : x = 110 Sanju :) On Fri, Aug 26, 2011 at 11:23 AM, gmagog...@gmail.com gmagog...@gmail.comwrote: @Rahul Assume the productivity of each man is the same let original number of man be x The total workload= x*10*p also workload = (x-10)(10+10)*p solve it so x=20 Yanan Cao On Fri, Aug 26, 2011 at 1:21 PM, Rahul Verma rahul08k...@gmail.comwrote: @yanan how it is 20. Rahul Verma -- 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/-/uIONcvrf6kUJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] apti!
In this question, instead of 10, it is 100. Check it again. Sanju :) On Fri, Aug 26, 2011 at 11:26 AM, Sanjay Rajpal srn...@gmail.com wrote: Sry for prrevious post . It is question of R S Aggarwal, and solved using conecpt of direct and indirect proportions. Originally,let there be x men. Less men,more days(indirect proposition) (x-10) : x :: 100 : 110 (x-10) * 110 = x * 100 ANS : x = 110 Sanju :) On Fri, Aug 26, 2011 at 11:23 AM, gmagog...@gmail.com gmagog...@gmail.com wrote: @Rahul Assume the productivity of each man is the same let original number of man be x The total workload= x*10*p also workload = (x-10)(10+10)*p solve it so x=20 Yanan Cao On Fri, Aug 26, 2011 at 1:21 PM, Rahul Verma rahul08k...@gmail.comwrote: @yanan how it is 20. Rahul Verma -- 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/-/uIONcvrf6kUJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] apti!
If it is 10 days originally, answer is 20 for sure. Sanju :) On Fri, Aug 26, 2011 at 11:27 AM, Sanjay Rajpal srn...@gmail.com wrote: In this question, instead of 10, it is 100. Check it again. Sanju :) On Fri, Aug 26, 2011 at 11:26 AM, Sanjay Rajpal srn...@gmail.com wrote: Sry for prrevious post . It is question of R S Aggarwal, and solved using conecpt of direct and indirect proportions. Originally,let there be x men. Less men,more days(indirect proposition) (x-10) : x :: 100 : 110 (x-10) * 110 = x * 100 ANS : x = 110 Sanju :) On Fri, Aug 26, 2011 at 11:23 AM, gmagog...@gmail.com gmagog...@gmail.com wrote: @Rahul Assume the productivity of each man is the same let original number of man be x The total workload= x*10*p also workload = (x-10)(10+10)*p solve it so x=20 Yanan Cao On Fri, Aug 26, 2011 at 1:21 PM, Rahul Verma rahul08k...@gmail.comwrote: @yanan how it is 20. Rahul Verma -- 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/-/uIONcvrf6kUJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] maximum XOR
+1 t jai. Sanju :) On Fri, Aug 26, 2011 at 9:46 PM, raj kumar megamonste...@gmail.com wrote: good test case jai -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Find the non-duplicate element in sorted array in O(n) time
@Venkat : suppose if the array were : 1 2 2 2 2 2 2 2 2 2 2, would ur solution work ? Sanju :) On Wed, Aug 24, 2011 at 3:58 AM, Ankit Minglani ankit.mingl...@gmail.comwrote: How about this : We use a divide and conquer approach and since the array is sorted. We find the middle element and check its value with its immediate left and right element .. it must match with anyone of them .. if it doesnt we have found such a element . and otherwise we divide the array again .. and then again find the middle element .. to check the same condition .. This will take O(lg n ) time :) On Wed, Aug 24, 2011 at 3:45 PM, Venkat venkataharishan...@gmail.comwrote: we can solve this with the help of binary search. we know N, which is odd(because of one pair missing) We divide it array. Let consider your input { 1,1,2,2,2,2,3,3,4,5,5} int find_culprit(int[] array, int start, int end) { if(end==start) return -1; int mid=((end-start) / 2) + start; if array[mid] == array[mid-1] return find_culprit(mid,end) if(array[mid] == array [mid +1] return find_culprit(start, mid); else return array[mid]; } Run through: Steps1: find_culprit(array,0,8) mid=4 Step 2 : find_culprit(array,4,8)) mid=6 step 3 : find_culprit(array,6,8)) mid=7 return array[7]=4 (which dont have pair) Run time O(log n+1) = O(log n) Please ask if you ve any doubts. Regards Venkat. On Aug 24, 2:49 pm, atul purohit gonewiththe...@gmail.com wrote: Hi, A* sorted *integer array contains elements in pairs. All the pairs are complete except one element whose pair is missing. Find that element. Ex. { 1,1,2,2,2,2,3,3,4,5,5} result = 5 There is a standard solution which returns an XOR of all the elements. But this needs O(n) time complexity. The person who asked me this question said that this can be done in O(n). Maybe we can eliminate some elements. Anyone knows how to do this? Cheers, Atul -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- The more you sweat in the field, the less you bleed in war. Ankit Minglani NITK Surathkal -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Find the non-duplicate element in sorted array in O(n) time
yes this is the only one till now, but i think we can do better also. Hope a better solution will be posted by someone soon. Sanju :) On Wed, Aug 24, 2011 at 5:22 AM, Venkat venkataharishan...@gmail.comwrote: @Sanju: For your input both above solution wont work... Do you ve any soultion for your input?? For your input Xor all numbers - will give you the result:) but its O(n) Anyway your input allow everyone to think little wider than Binay search. Thanks Venkat On Aug 24, 4:05 pm, Sanjay Rajpal srn...@gmail.com wrote: @Venkat : suppose if the array were : 1 2 2 2 2 2 2 2 2 2 2, would ur solution work ? Sanju :) On Wed, Aug 24, 2011 at 3:58 AM, Ankit Minglani ankit.mingl...@gmail.comwrote: How about this : We use a divide and conquer approach and since the array is sorted. We find the middle element and check its value with its immediate left and right element .. it must match with anyone of them .. if it doesnt we have found such a element . and otherwise we divide the array again .. and then again find the middle element .. to check the same condition .. This will take O(lg n ) time :) On Wed, Aug 24, 2011 at 3:45 PM, Venkat venkataharishan...@gmail.com wrote: we can solve this with the help of binary search. we know N, which is odd(because of one pair missing) We divide it array. Let consider your input { 1,1,2,2,2,2,3,3,4,5,5} int find_culprit(int[] array, int start, int end) { if(end==start) return -1; int mid=((end-start) / 2) + start; if array[mid] == array[mid-1] return find_culprit(mid,end) if(array[mid] == array [mid +1] return find_culprit(start, mid); else return array[mid]; } Run through: Steps1: find_culprit(array,0,8) mid=4 Step 2 : find_culprit(array,4,8)) mid=6 step 3 : find_culprit(array,6,8)) mid=7 return array[7]=4 (which dont have pair) Run time O(log n+1) = O(log n) Please ask if you ve any doubts. Regards Venkat. On Aug 24, 2:49 pm, atul purohit gonewiththe...@gmail.com wrote: Hi, A* sorted *integer array contains elements in pairs. All the pairs are complete except one element whose pair is missing. Find that element. Ex. { 1,1,2,2,2,2,3,3,4,5,5} result = 5 There is a standard solution which returns an XOR of all the elements. But this needs O(n) time complexity. The person who asked me this question said that this can be done in O(n). Maybe we can eliminate some elements. Anyone knows how to do this? Cheers, Atul -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- The more you sweat in the field, the less you bleed in war. Ankit Minglani NITK Surathkal -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] C code scanf problem
after first scanf, place a call to fflush(stdin). you will get the result. Sanju :) On Wed, Aug 24, 2011 at 5:58 AM, Mehnaaz mehnaazmohiud...@gmail.com wrote: #include stdio.h #define max 30 int no_p; int main() { char p[no_p][max]; char x; int i=0; printf(enter the no of productions..\n); scanf(%d, no_p); printf(you have entered :%d\n, no_p); printf(Variable who's FOLLOW you want\n); scanf(%c, x); printf(you have entered :%c,X); printf(\n); for( i =0 ; i no_p ; i++){ printf(enter the production # %d,i+1); scanf(%s,p[i]); } //follow(p,x); return 0; } the output i am getting goes like this .. enter the no of productions.. 3 you have entered :3 Variable who's FOLLOW you want you have entered : enter the production # 1 ... at the line 4 of the output its supposed to wait for my scanf() entry value right??..but it executes the printf after that giving you have entered i'm using gcc to compile this -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 Trick
nice solution priyanka :) Sanju :) On Wed, Aug 24, 2011 at 6:03 AM, priyanka raju priyark...@gmail.com wrote: int a,b,max,min; max=(a+b+abs(a-b))/2; min=(a+b-abs(a-b))/2; -- cheers priyanka -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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
assuming unsigned integers and 8-bit size,and n to be the number, logic is : n 4 | n 4. Correct me if m wrong. Sanju :) On Wed, Aug 24, 2011 at 8:51 AM, aditi garg aditi.garg.6...@gmail.comwrote: though im very unsure abt this,but how abt converting the number to BCD and then normal swapping of the two nibbles?? Bt i guess this would work only for 2 digit numbers... On Wed, Aug 24, 2011 at 8:20 PM, aditya kumar aditya.kumar130...@gmail.com wrote: does anyone know the correct solution this problem ?? problem : i/p :: 39 o/p:: 93 (using bitwise operator) On Fri, Aug 12, 2011 at 1:41 PM, Prakash D cegprak...@gmail.com wrote: how does the above code work? On Fri, Aug 12, 2011 at 1:14 PM, Rahul raikra...@gmail.com wrote: I understand. where I find some more tricks like these , I mean I really. find. bit thinking hacks. difficult to understand. On 8/12/11, Tarun Arya tarun@gmail.com wrote: RAHUL@ d question was to reverse d 2 numbers...it can b done by wat i hav said... if u want 2 extract numbers then a0x0f //this wil giv number in units place... a0xf0 a4//this wil give number in tens place correct me if i m wrong Tarun -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Rahul -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Aditi Garg Undergraduate Student Electronics Communication Divison NETAJI SUBHAS INSTITUTE OF TECHNOLOGY Sector 3, Dwarka New 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 an array, find out whether there exists a triplet which can form sides of triangle.
This problem is already discussed in one of the earlier posts. Sanju :) On Tue, Aug 23, 2011 at 12:15 AM, darklord darklord@gmail.com wrote: @dave: sorry I overlooked the constraint u cannot modify the array space is mandatory then. On Aug 23, 12:07 pm, darklord darklord@gmail.com wrote: mofified array will be C[0]=1 C[1]=2 C[2]=5 C[3]=8 C[4]=10 C[5]=20 @saurabh: obviously it does! @Dave: no need of extra space also u can use quicksort. I think if u r using extra space, U can do it in linear time using radixsort (correct me if I'm wrong). On Aug 23, 11:44 am, Raghavan its...@gmail.com wrote: A[0] = 10A[1] = 2A[2] = 5 A[3] = 1A[4] = 8A[5] = 20 Triplet 10,5,8 is triangular. Dave, do your solution do it? On Tue, Aug 23, 2011 at 11:55 AM, Amol Sharma amolsharm...@gmail.com wrote: +1 for dave's solution.i will also do the same -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad http://gplus.to/amolsharma99 http://twitter.com/amolsharma99 http://in.linkedin.com/pub/amol-sharma/21/79b/507 http://youtube.com/amolsharma99 On Tue, Aug 23, 2011 at 11:25 AM, Dave dave_and_da...@juno.com wrote: @Saurabh: If you can use O(n) extra space, make a copy of the array and sort it: O(n log n). Then, if there is a solution, there will be a solution of the form (a[i], a[i+1], a[i+2]), where 0 = i n-2, which can be checked with a simple for loop: O(n). Thus, the complexity is O(n log n). Dave On Aug 23, 12:04 am, saurabh agrawal saurabh...@gmail.com wrote: Given an array, find out whether there exists a triplet which can form sides of triangle. You are not allowed to modify the array. PLease dont give o(n^3) solution there exists a solution with nlog(n) i think -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Thanks and Regards, Raghavan KL -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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-question
to clear ur these concepts , i think u should refer to Programming in C , Schaum series, Byron S Gottfried, and then Ritchie book. They are clearly given there. Sanju :) On Mon, Aug 22, 2011 at 11:25 PM, Vijay Khandar vijaykhand...@gmail.comwrote: Thanks ...got it.. On Tue, Aug 23, 2011 at 11:30 AM, binayakranjan das binayakran...@gmail.com wrote: In this case = has right to left associativity and as such has no associativity.but,the parsing occurs from left to right.so first (xy) is checked which evaluates to 0 then (0z) which evaluates to 1 and that is what is assigned to i. On Aug 23, 10:33 am, Vijay Khandar vijaykhand...@gmail.com wrote: main() { int x=10,y=10,z=5; int i=xyz; pf(\n%d,i); } o/p is 1 .pls any1 explain me hw is it printing? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Re: C dot
7.7 LPA @ NIT Kurukshetra. Sanju :) On Mon, Aug 22, 2011 at 10:47 PM, siddharam suresh siddharam@gmail.comwrote: how much they are offering ? Thank you, Siddharam On Tue, Aug 23, 2011 at 11:12 AM, ranjith kumar v.ranjithcar...@gmail.com wrote: They shortlist candidates based on cgpa and select the highest cgpa candidate. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Benefits of using Private or Protected Virtual Functions ?
I think they can be useful in singlton classes. Sanju :) On Tue, Aug 23, 2011 at 3:32 AM, sachin sabbarwal algowithsac...@gmail.comwrote: i can't come up with benefits... but a potential use is here class c1 { private: c1() { } public: static c1* makeobject(accept credentials) { //check for privileges //if requester is privileged then make an object.(check credentials) //make an object by calling constructor explicitly return object; } }; int main() { c1 *obj1; obj1 = c1::makeobject(my credentials); } //as constructor is private , we can't make an object directly. we'll let the class decide who can make an object of it. // if the class finds the requester privileged then it would let it create an object otherwise give error. correct me if i'm wrong, or tell me if you need more explanation. On Mon, Aug 22, 2011 at 9:42 AM, Decipher ankurseth...@gmail.com wrote: -- 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/-/TSCBDch6GdYJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] C Trick
@teja : use of comparison operator is not allowed. Sanju :) On Tue, Aug 23, 2011 at 6:42 AM, teja bala pawanjalsa.t...@gmail.comwrote: int a,b,c; c=(ab)?a:b; print(c); On Tue, Aug 23, 2011 at 6:37 PM, Abhishek Yadav algowithabhis...@gmail.com wrote: Write a method which finds the maximum of two numbers You should not use if-else or any other comparison operator. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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]
Hi frnds, I need Data Structures and Algorithm book by Andrew S Tanenbaum. Plz post a link or mail the book at srn...@gmail.com Thanx in Advance :) Sanju :) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Accessing private members of Derived class ?
Here concept of v-tables comes into picture. Refer to C++ Primer Plus by Stephen Prata. Sanju :) On Sun, Aug 21, 2011 at 11:05 PM, JAIDEV YADAV jaid...@gmail.com wrote: because Access control check is done at compile time while using virtual make fun not available to the base class pointer till runtime ... so no access check to derived class ... hope u understand and correct me to if there is any mistake ... On Mon, Aug 22, 2011 at 10:57 AM, Decipher ankurseth...@gmail.com wrote: class Base { public : virtual void show() { cout\n Base ; } }; class Derived : public Base { private : void show() { cout\n Derived ; } }; int main() { Base *d = new Derived(); d-show(); getch(); } Why Derived::show is called even though it is private ? (Ran this code on Dev - C++) -- 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/-/MKvMpI_KOLUJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- JaiDev Yadav (National Yoga Champion) Computer Engg. Dept. National Institute of Technology Kurukshetra,Haryana -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Macro for Swapping
+1 to saurabh. Sanju :) On Sun, Aug 21, 2011 at 10:21 PM, saurabh singh saurab...@gmail.com wrote: http://www.ideone.com/SlFsw On Mon, Aug 22, 2011 at 10:41 AM, Decipher ankurseth...@gmail.com wrote: Write a macro to swap integers , floating point , chars and pointers ? -- 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/-/hYyEh3PaS_QJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Book
Design and Analysis of Algorithms, Aho, Ullman and Hopcroft, Pearson Education . anybody having this book, plz mail at srn...@gmail.com or post a download link here. Sanju :) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.