Re: [algogeeks] Re: Highest reminder
Hi, 23 = 11 X 1 + 12. Thus 12 would the highest remainder. Not 11 On Thu, May 30, 2013 at 10:24 AM, Sreenivas Sigharam sighar...@gmail.comwrote: Dave's explanation was clear..and informative.. Thank you Dave.. Thank you , Soumya Prasad, for a simple but nice topic.. Thank you, Sigharam. On Thu, May 30, 2013 at 10:16 AM, Sanjay Rajpal sanjay.raj...@live.inwrote: 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. -- 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* -- 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] searching all matching words in a Trie with a given filter.
Don, I'm trying to get all the words from trie iteratively, because I'm creating trie of whole dictionary (more than 200k words) and searching recursively will consume a lot of stack space. Thanks for your help! On Wed, May 29, 2013 at 9:44 AM, rahul sharma rahul23111...@gmail.comwrote: @don u r searching in a previously built trie with the given filter...then wat is this add fxn doing?correct me if m getting u wrng On Wednesday, May 29, 2013, avinesh saini avinesh.sa...@gmail.com wrote: Thank you Don, I was also trying in similar way. But here I'm confused how you are storing the traversed words. Are you adding whole words at the node on which word is ending during insertion. On Wed, May 29, 2013 at 12:36 AM, Don dondod...@gmail.com wrote: void findWords(trie *root, char *filter) { if (!root) return; if (*filter == 0) // When you reach the end of the filter at the end of a valid word, add the word. { if (root-words) words.add(root-word); } else if (*filter == '.') // Search for words with any letter { for(int i = 'a'; i = 'z' ; ++i) findWords(root-link[i], filter+1); } else // Search for words with the required letter { findWords(root-link[*filter], filter+1); } } On May 28, 4:47 am, avinesh saini avinesh.sa...@gmail.com wrote: How to search all the matching words for a filter in a trie. e.g. searching by filter ...r..m will find all the words(of length = 7) in trie in which 4th character is 'r' and 7th character is 'm'. -- * * *thanks regards,* *Avinesh * -- 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. -- thanks regards, Avinesh -- 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. -- * * *regards,* *Avinesh Kumar National Institute of Technology, Calicut.* *Kerala- 673601* *+91 7849080702* *http://www.facebook.com/avinesh.saini* -- 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] Re: searching all matching words in a Trie with a given filter.
It won't use a lot of stack space because the stack space is related to the depth of the trie which is only as deep as the length of the longest word. But I'm all for doing it iteratively. Don On May 30, 7:57 am, avinesh saini avinesh.sa...@gmail.com wrote: Don, I'm trying to get all the words from trie iteratively, because I'm creating trie of whole dictionary (more than 200k words) and searching recursively will consume a lot of stack space. Thanks for your help! On Wed, May 29, 2013 at 9:44 AM, rahul sharma rahul23111...@gmail.comwrote: @don u r searching in a previously built trie with the given filter...then wat is this add fxn doing?correct me if m getting u wrng On Wednesday, May 29, 2013, avinesh saini avinesh.sa...@gmail.com wrote: Thank you Don, I was also trying in similar way. But here I'm confused how you are storing the traversed words. Are you adding whole words at the node on which word is ending during insertion. On Wed, May 29, 2013 at 12:36 AM, Don dondod...@gmail.com wrote: void findWords(trie *root, char *filter) { if (!root) return; if (*filter == 0) // When you reach the end of the filter at the end of a valid word, add the word. { if (root-words) words.add(root-word); } else if (*filter == '.') // Search for words with any letter { for(int i = 'a'; i = 'z' ; ++i) findWords(root-link[i], filter+1); } else // Search for words with the required letter { findWords(root-link[*filter], filter+1); } } On May 28, 4:47 am, avinesh saini avinesh.sa...@gmail.com wrote: How to search all the matching words for a filter in a trie. e.g. searching by filter ...r..m will find all the words(of length = 7) in trie in which 4th character is 'r' and 7th character is 'm'. -- * * *thanks regards,* *Avinesh * -- 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. -- thanks regards, Avinesh -- 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. -- * * *regards,* *Avinesh Kumar National Institute of Technology, Calicut.* *Kerala- 673601* *+91 7849080702* *http://www.facebook.com/avinesh.saini* -- 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] Re: searching all matching words in a Trie with a given filter.
Sorry, that was not really clear. I was just adding the newly found word to a list of words. That list will be the output. I treated it as if it was declared globally. It would be better form to pass the list in as a reference, or to have the function return the list. Don On May 29, 12:14 am, rahul sharma rahul23111...@gmail.com wrote: @don u r searching in a previously built trie with the given filter...then wat is this add fxn doing?correct me if m getting u wrngOn Wednesday, May 29, 2013, avinesh saini avinesh.sa...@gmail.com wrote: Thank you Don, I was also trying in similar way. But here I'm confused how you are storing the traversed words. Are you adding whole words at the node on which word is ending during insertion. On Wed, May 29, 2013 at 12:36 AM, Don dondod...@gmail.com wrote: void findWords(trie *root, char *filter) { if (!root) return; if (*filter == 0) // When you reach the end of the filter at the end of a valid word, add the word. { if (root-words) words.add(root-word); } else if (*filter == '.') // Search for words with any letter { for(int i = 'a'; i = 'z' ; ++i) findWords(root-link[i], filter+1); } else // Search for words with the required letter { findWords(root-link[*filter], filter+1); } } On May 28, 4:47 am, avinesh saini avinesh.sa...@gmail.com wrote: How to search all the matching words for a filter in a trie. e.g. searching by filter ...r..m will find all the words(of length = 7) in trie in which 4th character is 'r' and 7th character is 'm'. -- * * *thanks regards,* *Avinesh * -- 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. -- thanks regards, Avinesh -- 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.