Re: [algogeeks] max of 2 numbers
max=x + ( ( x - y ) ( ( x - y ) 31 )) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] c book
thanxs yar On Sun, Jun 20, 2010 at 7:00 AM, sharad kumar aryansmit3...@gmail.comwrote: @vishal :pls read How to program C Deitel and Deitel.its best book i have ever read... On Sun, Jun 20, 2010 at 1:21 AM, vishard sankhyan er.vish...@gmail.comwrote: hii pls suggest me a book for c, i just want to make my base strong.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- yezhu malai vaasa venkataramana Govinda Govinda -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] ACTIVATION OF WINDOWS 7
HI ANY ONE HELP OUT I WANT TO ACTIVATE MY WINDOWS 7.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] ACTIVATION OF WINDOWS 7
So, is this the place for that? And apart from that, it is illegal to discuss about this on public threads. (if you don't know, this thread is public) -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Sun, Jun 20, 2010 at 2:42 PM, vishard sankhyan er.vish...@gmail.comwrote: HI ANY ONE HELP OUT I WANT TO ACTIVATE MY WINDOWS 7.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] There is an array of odd and even numbers. Now, sort them in such a way that the top portion of the array contains odd numbers, bottom portion contains even numbers
Why not just change the definition of when one number is bigger than another and do normal sort ? I guess that is better and simpler. -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Sun, Jun 20, 2010 at 7:52 AM, Anurag Sharma anuragvic...@gmail.comwrote: Keep 2 pointers 'start' and 'end' and make them point to start and beginning of the array. Now keep decresing *end* pointer until an odd element is found Keep increasing the *start* pointer until an even element is found swap the elements at start and end Continue the above 3 steps till startend Now the start/end points to a border element which divides the array in 2 parts, 1st have having all odd numbers and 2nd half with all even numbers. Now use any inplace sorting algorithm to sort in descending order the portion containing all odd numbers and in increasing order the portion containing all even numbers. Hope its clear. Anurag Sharma On Sun, Jun 20, 2010 at 2:15 AM, vijay auvija...@gmail.com wrote: There is an array of odd and even numbers. Now, sort them in such a way that the top portion of the array contains odd numbers, bottom portion contains even numbers. The odd numbers are to be sorted in descending order and the even numbers in ascending order. You are not allowed to use any extra array and it has to use a conventional sorting mechanism and should not do any pre or post processing -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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: SPOJ:RRSCHED
You must be doing some useless iterations . Otherwise, TLE is too strange for this prob. -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Sat, Jun 19, 2010 at 9:15 AM, Shravan shravann1...@gmail.com wrote: Even I have implemented it using arrays, but I am getting a TLE. Here's the code http://ideone.com/EfYRa On Jun 19, 8:15 am, Anand anandut2...@gmail.com wrote: It can be done using simple array data structure why do we need complex data structure. Here is how I did. Let me know if I understood correctly. http://codepad.org/rMbTI8PJ On Fri, Jun 18, 2010 at 8:15 AM, Shravan shravann1...@gmail.com wrote: I am trying to solve the problemhttp://www.spoj.pl/problems/RRSCHED/ . And a naive approach doesn't seem to work .What sort of data structure do I need. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] finding nearest neighbour
It was my lab assignment prob last year. Will send u if i happen to find it by chance. -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Mon, Jun 14, 2010 at 10:31 PM, Jitendra Kushwaha jitendra.th...@gmail.com wrote: Given n points in the space. Now given a new point you have to find the nearest neigbour to it from initial n points This can be done in O(n), a trivial solution. This can also be accomplished in O(logn) by space partioning. here is a link: http://en.wikipedia.org/wiki/Nearest_neighbor_search#Space_partitioning can anybody give a pseudo code or commented C code to impliment it. I do not understood how to implement it. this is a google interview question and its variation is a amazon's question. :) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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 code.....explaine output
it caculate the sum of two numbers. #includestdio.h int main() { int a=7,b=2,s; char *p; p=(char *)a; s= (int)p[b]; //adding a b//HOW printf(sum=%d\n,s); return 0; } can any one explain the code..?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] queue
Give a good data structure for having n queues ( n not fixed) in a finite memory segment. You can have some data-structure separate for each queue. Try to use at least 90% of the memory space. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Count Structurally different binary tree possible ..
IF i have given N node binary Search Tree . How to count how many Structurally different binary tree are possible in that Tree. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] max of 2 numbers
max = x-((x-y)(x-y)sizeof(int)*8 -1 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] max of 2 numbers
@anand it should be max=x - ( ( x - y ) ( ( x - y ) 31 )) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] ACTIVATION OF WINDOWS 7
May be if you want to discuss what sort of algorithms MS might be using to generate the serial key, then this is the right place :D Kishen On Sun, Jun 20, 2010 at 4:16 AM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote: So, is this the place for that? And apart from that, it is illegal to discuss about this on public threads. (if you don't know, this thread is public) -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Sun, Jun 20, 2010 at 2:42 PM, vishard sankhyan er.vish...@gmail.comwrote: HI ANY ONE HELP OUT I WANT TO ACTIVATE MY WINDOWS 7.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: SPOJ:RRSCHED
Did you see the code which I have posted. On Jun 20, 2:31 pm, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: You must be doing some useless iterations . Otherwise, TLE is too strange for this prob. -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombayhttp://www.cse.iitb.ac.in/~rohitfeb14 On Sat, Jun 19, 2010 at 9:15 AM, Shravan shravann1...@gmail.com wrote: Even I have implemented it using arrays, but I am getting a TLE. Here's the code http://ideone.com/EfYRa On Jun 19, 8:15 am, Anand anandut2...@gmail.com wrote: It can be done using simple array data structure why do we need complex data structure. Here is how I did. Let me know if I understood correctly. http://codepad.org/rMbTI8PJ On Fri, Jun 18, 2010 at 8:15 AM, Shravan shravann1...@gmail.com wrote: I am trying to solve the problemhttp://www.spoj.pl/problems/RRSCHED/ . And a naive approach doesn't seem to work .What sort of data structure do I need. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] max of 2 numbers
@ above , ? operators are not allowed. @ anand can u please explain how this works max=x + ( ( x - y ) ( ( x - y ) 31 )) On Sun, Jun 20, 2010 at 1:16 PM, anand verma anandandymn...@gmail.comwrote: max=x + ( ( x - y ) ( ( x - y ) 31 )) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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: SPOJ:RRSCHED
No -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Sun, Jun 20, 2010 at 3:22 PM, Shravan shravann1...@gmail.com wrote: Did you see the code which I have posted. On Jun 20, 2:31 pm, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: You must be doing some useless iterations . Otherwise, TLE is too strange for this prob. -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombayhttp://www.cse.iitb.ac.in/~rohitfeb14 On Sat, Jun 19, 2010 at 9:15 AM, Shravan shravann1...@gmail.com wrote: Even I have implemented it using arrays, but I am getting a TLE. Here's the code http://ideone.com/EfYRa On Jun 19, 8:15 am, Anand anandut2...@gmail.com wrote: It can be done using simple array data structure why do we need complex data structure. Here is how I did. Let me know if I understood correctly. http://codepad.org/rMbTI8PJ On Fri, Jun 18, 2010 at 8:15 AM, Shravan shravann1...@gmail.com wrote: I am trying to solve the problemhttp:// www.spoj.pl/problems/RRSCHED/ . And a naive approach doesn't seem to work .What sort of data structure do I need. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@googlegroups.comalgogeeks%252bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@googlegroups.comalgogeeks%252bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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.....explaine output
@anand:its similar to reference an array element using pointer...*(p+i) which is imilar to p[i] when u put *before the value gets dereferenced and hence p+i takes place same concept On Sun, Jun 20, 2010 at 3:27 PM, anand anandandymn...@gmail.com wrote: it caculate the sum of two numbers. #includestdio.h int main() { int a=7,b=2,s; char *p; p=(char *)a; s= (int)p[b]; //adding a b//HOW printf(sum=%d\n,s); return 0; } can any one explain the code..?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- yezhu malai vaasa venkataramana Govinda Govinda -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] c code.....explaine output
@anand:he takes the value at particular byte by using char*...same u do for chcking endianess rite...same concept On Sun, Jun 20, 2010 at 3:39 PM, sharad kumar aryansmit3...@gmail.comwrote: @anand:its similar to reference an array element using pointer...*(p+i) which is imilar to p[i] when u put *before the value gets dereferenced and hence p+i takes place same concept On Sun, Jun 20, 2010 at 3:27 PM, anand anandandymn...@gmail.com wrote: it caculate the sum of two numbers. #includestdio.h int main() { int a=7,b=2,s; char *p; p=(char *)a; s= (int)p[b]; //adding a b//HOW printf(sum=%d\n,s); return 0; } can any one explain the code..?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- yezhu malai vaasa venkataramana Govinda Govinda -- yezhu malai vaasa venkataramana Govinda Govinda -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] balance tree
Given an incoming stream of sorted numbers construct a binary search tree. At each stage, you should have a nearly balanced tree. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] balance tree
no ...if buffer is given then its trivial... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] back edges
can any one tell an algorithm to find back edges in a directed graph. and is there any other way also to find cycles in a directed graph...?? -- With Regards, Jalaj Jaiswal +919026283397 B.TECH IT IIIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Integer from number in words
You need to specify the max level upto which you want it to work. For rest, is there any prob? I can't see any. you see ninety - 90 u see thousand - 90*1000 + and so on -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Sun, Jun 20, 2010 at 6:34 PM, debajyotisarma sarma.debajy...@gmail.comwrote: How to device an algorithm for converting the number given in words to an int? Eg: i/p : ninety thousand two hundred fourth three o/p: 90243 even the number can be very big ... in million or billion ... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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: coins
No, even if they are unsorted still it will be the same b'cos we check for iV[j] for the second loop. On Sat, Jun 19, 2010 at 8:41 PM, Chakravarthi Muppalla chakri...@gmail.comwrote: O(S +n ) only when the denominations are in sorted order.isn't it? On Sun, Jun 20, 2010 at 8:41 AM, Anand anandut2...@gmail.com wrote: Complexity will be O(S+n) S = Sum required N = Number of denominations On Sat, Jun 19, 2010 at 12:48 PM, Chakravarthi Muppalla chakri...@gmail.com wrote: Hi anand, could you please enlighten on the running time of the code? On Sun, Jun 20, 2010 at 1:12 AM, Anand anandut2...@gmail.com wrote: Here is my approach for solving this problem using DP. http://codepad.org/Op41weg5 http://codepad.org/Op41weg5 On Thu, Jun 17, 2010 at 6:33 AM, Chakravarthi Muppalla chakri...@gmail.com wrote: I think that we need to go by dynamic programming. Ex: 1,3,7,4,9 T=23 Sort: 1,3,4,7,9 subtract max value from T(23-9=14 ) find Best Solution for (14) -- sub (14-9 = 5), Search for 5.(5-4 = 1) So Answer would be: 9,9,4,1 Search can be binary search as the array is already sorted. At every step best solution for the specified number could be saved in a hash table for any further references. Thanks Regards, Chakravarthi. On Thu, Jun 17, 2010 at 6:10 PM, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: Yes right, i forgot the 1 -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14 On Thu, Jun 17, 2010 at 6:05 PM, Dave dave_and_da...@juno.comwrote: No. The greedy algorithm also works on the U.S. coinage system, where the coins are 1, 5, 10, 25. Again, the rule is that there must be a 1 unit coin, and each coin has at least twice the value of the preceeding one. Dave On Jun 16, 11:34 pm, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: @Dave: The greedy will only work if the coins are k,2k,3k,4k, nk without any of these missing Clear? (Perhaps i did not write it clearly as i was on mobile) -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombayhttp://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14 On Thu, Jun 17, 2010 at 10:00 AM, Dave dave_and_da...@juno.com wrote: The greedy algorithm doesn't work, e.g., when the coins are 1, 5, and 8 units, and you want to make 15 units. In this case, the greedy algorithm would choose 8, 5, 1, 1, whereas the optimal is 5, 5, 5. I believe the criterion for the greedy algorithm are that the smallest coin be 1 unit and each successive coin be at least twice the value of its predecessor. Dave On Jun 16, 9:19 pm, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: If the coins are all multiple of some number k, you can greedily give as much as possible to the higher domination. Otherwise still, there is an optimal substructure and u can make a recurrence and use memoization(i.e. DP) -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombayhttp://www.cse.iitb.ac.in/~rohitfeb14http://www.cse.iitb.ac.in/%7Erohitfeb14 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Thanks, Chakravarthi. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to
Re: [algogeeks] Integer from number in words
On Sun, Jun 20, 2010 at 6:34 PM, debajyotisarma sarma.debajy...@gmail.comwrote: How to device an algorithm for converting the number given in words to an int? Eg: i/p : ninety thousand two hundred fourth three o/p: 90243 even the number can be very big ... in million or billion ... Here i/p should be read from left to right word by word.Each keyword and its value must be stored prehand 1-1 mapping.eg. ninety=90 ,thousand =1000 and all these keyword values are multiplied and added(90*1000+2*100+43=90243) and number is generated. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Thanks Regards Nikhil Agarwal Senior Undergraduate Computer Science Engineering, National Institute Of Technology, Durgapur,India http://tech-nikk.blogspot.com http://beta.freshersworld.com/communities/nitd -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] back edges
how to identify a back edge while doin dfs is wht m asking On Sun, Jun 20, 2010 at 6:23 PM, Piyush Verma 114piy...@gmail.com wrote: back edge is usefull to find a cycle in graph in finding cycle algorithm ( using DFS) we mark every edge as back edge or tree edge then traverse again total number of back edges give the number of cycle present in directed graph. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- With Regards, Jalaj Jaiswal +919026283397 B.TECH IT IIIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] back edges
You start from a vertex, then if you reach that vertex before dfs on that vertex finishes, then the edge u used to reach it is a back edge. And if you reach after the dfs finishes on that node, it's a cross edge. -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Sun, Jun 20, 2010 at 6:23 PM, Piyush Verma 114piy...@gmail.com wrote: back edge is usefull to find a cycle in graph in finding cycle algorithm ( using DFS) we mark every edge as back edge or tree edge then traverse again total number of back edges give the number of cycle present in directed graph. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] queue
there is a linked list where each node of linked list points to queue.. for eg. 1st node points to queue 1 2nd to queue 2 nd so on.. hope m clear this time.. On 20 June 2010 18:30, Piyush Verma 114piy...@gmail.com wrote: @divya plzz explain little more. m not getting... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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] palindrome substring
Here is code to find palindrome in linear time: http://codepad.org/PMJzjpPJ On Fri, Jun 18, 2010 at 5:28 AM, Chunyuan Ge hhy...@gmail.com wrote: good point, i am wrong, sorry On Fri, Jun 18, 2010 at 5:54 PM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote: abcqwertycba So is abc a palindrome?? -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 On Fri, Jun 18, 2010 at 3:08 PM, Chunyuan Ge hhy...@gmail.com wrote: Origin string a, reverse the string to get b get the longest common string between a and b that's it. Chunyuan On Thu, Jun 17, 2010 at 8:38 PM, debajyotisarma sarma.debajy...@gmail.com wrote: Find the longest palindrome in the given string. Minimum time-space complexity required (i have not solved it so don't know what is min) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from 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.....explaine output
p=(char *)a; this statement assigns value of 7 to p after type converting to char*, so as p is a pointer it points to memory location 7 p[b] will give to the value at location 9 same as *(p+b) = *(7 + 2) just like array p[b] will give the address of that location i.e. 9 which is char* so we type convert to int and assigned to s. On 6/20/10, jalaj jaiswal jalaj.jaiswa...@gmail.com wrote: @ above all i dint get how the value of a and b gets added in s... after p=(char *)a... p has 7 in it... but how the value gets added thru s=(int)p[b] p[b] seems as if p is an array.. m confused in this line .. please explain in a bit detail.. :O On Sun, Jun 20, 2010 at 4:44 PM, anand verma anandandymn...@gmail.comwrote: thanks -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- With Regards, Jalaj Jaiswal +919026283397 B.TECH IT IIIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. 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 algoge...@googlegroups.com. To unsubscribe from 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] min no of policemen
A Little late in replying but: This can be solved using *Dynamic programming* or Memoization in O( |V| ) |V| - Number of nodes in the tree. Here is the rough idea of the algorithm: Step1: Arbitrarily select a node of the tree as root. Step2: result = minimum( min_police( root, false ), min_police(root,true) + 1) /* r - root of the subtree we're solving for covered - a flag denoting whether the current node contains a police */ *min_police( r, covered ) : result = 0 /* the current node contains the police man so the adjacent nodes may / may not have a police man. */ if( covered ) for each vertex v1 adjacent to r do result = result + minimum ( min_police(v1, false), min_police(v1,1) + 1 )* *return result else /* -current node doesn't contain a police man so at least one of the adjacent nodes must have a police man. - we initially find the minimum number of police men by not considering the above restriction - if in the process of greedily assigning policemen we had assigned a policeman to one of the adjacent nodes then we do nothing - otherwise we need to assign policeman to the node where the difference between number policemen in two cases is least. */ min_c_diff = int_max min_c_dif_node = -1 **for each vertex v1 adjacent to r do c1 = min_police( v1,false) c2 = min_police(v1,1) + 1 if c1 c2 if min_c_diff c2-c1 min_c_diff = c2-c1 min_c_diff_node = v1 result = result + minimum ( c1,c2 )* * if min_c_diff 0: result = result - min_c_diff* *return result** * I have not included the Dynamic programming or Memoization part here but you can extend the idea and implement it. And what you have asked is the special case of a general problem Vertex Cover in a graph. http://en.wikipedia.org/wiki/Vertex_cover It is considered NP-complete for general graphs. But for the trees it can be solved in O(|V|) using the above explained algorithm. Hoping it helps. On Tue, Jun 8, 2010 at 9:08 PM, Raj N rajn...@gmail.com wrote: @sharad: Can u explain topological sort here? On Tue, Jun 8, 2010 at 12:06 PM, divya jain sweetdivya@gmail.comwrote: @sharad.. sorry bt i dint get how to use bellman ford or topological sort here... can u plz explain... On 8 June 2010 05:53, sharad kumar aryansmit3...@gmail.com wrote: for placing police man we can use bellman ford bfs.or even make use of topological sort. On Mon, Jun 7, 2010 at 9:59 PM, divya sweetdivya@gmail.com wrote: consider a tree. policemen is to be placed such that for each edge of tree, there is a policeman on atleast one side of each edge. tell the min no. of policemen and their locatn in time O(n) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- yezhu malai vaasa venkataramana Govinda Govinda -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Thanks and regards Rizwan A Hudda http://sites.google.com/site/rizwanhudda -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this
Re: [algogeeks] queue
@divya if ith queue is full and i want to enque some value in ith queue then what should be the condition -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] back edges
@Rohit : i may be the decendant node of node j. initially DFS iteration starts from node i, if decendant's condition occur then mark edge (i,j) as back edge. (here j is the node which may be not visited). -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] lexicographically next string
write a c code to print lexicographically next string of the given word i.e as in dictionary next word after this word having similar letters for ex i/pabcd o/p abdc -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] STRONG ACTION GIRL REAL STUNTS SWEET AND SEXY http://businproz.blogspot.com/ http://businproz.blogspot.com/ http://businproz.blogspot.com/
STRONG ACTION GIRL REAL STUNTS SWEET AND SEXY http://businproz.blogspot.com/ http://businproz.blogspot.com/ http://businproz.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 algoge...@googlegroups.com. To unsubscribe from 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] STRONG ACTION GIRL REAL STUNTS SWEET AND SEXY http://businproz.blogspot.com/ http://businproz.blogspot.com/ http://businproz.blogspot.com/
Someone ban this spammer -- -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] n ary tree
Given two n-ary trees T1 and T2. Write a program to check if T1 has T2 in it. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from 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] lexicographically next string
is this approach works 1. write the post order traversal of T1 and T2 and save it in strings P1 and P2. 2. similarly write the In order traversal of T1 and T2, saving it in strings I1 and I2. 3. if T1 contains T2, then P1 contains P2 and I1 contains I2 as substrings. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.