[algogeeks] Re: Dynamic Programming Problem SPOJ-AMR11A
If you need hint: I used DP (Dynamic Programming) to solve this and get AC (Accepted). I stored the matrix as 2-D array and then started with array[R][C]. From there I can go upward and left. In each element of array put the minimum possible value to get the array[R][C]. In case, if we get the value = 0 substitute it by 1 because values =0 are not allowed. Follow this procedure up to array[1][1] which is your final answer. I don't know what's wrong with your approach as I don't have enough time to examine it. Here is my solution: http://pastebin.com/Cwah24Xi -- 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/-/9t6zsIUpYWYJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Anagram problem
sort the list,sort the word(use quick sort(nlogn time))- and den search using binary search(logn time) or we can evn do by hashing-hash the word,den for every word keep decreasing the counter,if the hash array is zero ,anagram,else reset the hash array for given input for the checking the next word. On Wed, Jul 18, 2012 at 2:07 AM, Navin Kumar algorithm.i...@gmail.comwrote: Assuming a preexisting list of 100 words, how would you efficiently see if a word received from input is an anagram of any of the 100 words? -- 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/-/5kuxjymYEc4J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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.
Re: [algogeeks] Anagram problem
^sorting a string would be o(n^2logn) if u use q.sort.count sort would be better. Saurabh Singh B.Tech (Computer Science) MNNIT blog:geekinessthecoolway.blogspot.com On Wed, Jul 18, 2012 at 1:08 PM, vindhya chhabra vindhyachha...@gmail.comwrote: sort the list,sort the word(use quick sort(nlogn time))- and den search using binary search(logn time) or we can evn do by hashing-hash the word,den for every word keep decreasing the counter,if the hash array is zero ,anagram,else reset the hash array for given input for the checking the next word. On Wed, Jul 18, 2012 at 2:07 AM, Navin Kumar algorithm.i...@gmail.comwrote: Assuming a preexisting list of 100 words, how would you efficiently see if a word received from input is an anagram of any of the 100 words? -- 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/-/5kuxjymYEc4J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Anagram problem
yes,sorry count sort will be O(n) so better.thanks On Wed, Jul 18, 2012 at 1:43 PM, saurabh singh saurab...@gmail.com wrote: ^sorting a string would be o(n^2logn) if u use q.sort.count sort would be better. Saurabh Singh B.Tech (Computer Science) MNNIT blog:geekinessthecoolway.blogspot.com On Wed, Jul 18, 2012 at 1:08 PM, vindhya chhabra vindhyachha...@gmail.com wrote: sort the list,sort the word(use quick sort(nlogn time))- and den search using binary search(logn time) or we can evn do by hashing-hash the word,den for every word keep decreasing the counter,if the hash array is zero ,anagram,else reset the hash array for given input for the checking the next word. On Wed, Jul 18, 2012 at 2:07 AM, Navin Kumar algorithm.i...@gmail.comwrote: Assuming a preexisting list of 100 words, how would you efficiently see if a word received from input is an anagram of any of the 100 words? -- 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/-/5kuxjymYEc4J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- 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.
[algogeeks]
#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.
Re: [algogeeks]
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.
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] Anagram problem
Sort each of the word and form a trie , if any words comes again you get one sch case. On Wed, Jul 18, 2012 at 2:12 PM, vindhya chhabra vindhyachha...@gmail.comwrote: yes,sorry count sort will be O(n) so better.thanks On Wed, Jul 18, 2012 at 1:43 PM, saurabh singh saurab...@gmail.comwrote: ^sorting a string would be o(n^2logn) if u use q.sort.count sort would be better. Saurabh Singh B.Tech (Computer Science) MNNIT blog:geekinessthecoolway.blogspot.com On Wed, Jul 18, 2012 at 1:08 PM, vindhya chhabra vindhyachha...@gmail.com wrote: sort the list,sort the word(use quick sort(nlogn time))- and den search using binary search(logn time) or we can evn do by hashing-hash the word,den for every word keep decreasing the counter,if the hash array is zero ,anagram,else reset the hash array for given input for the checking the next word. On Wed, Jul 18, 2012 at 2:07 AM, Navin Kumar algorithm.i...@gmail.comwrote: Assuming a preexisting list of 100 words, how would you efficiently see if a word received from input is an anagram of any of the 100 words? -- 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/-/5kuxjymYEc4J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- 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. -- Thanks regards Bhupendra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Anagram problem
sort each word in the list,then sort the whole list. Now,sort the input word(string). and then use binary search to find the word. On Wed, Jul 18, 2012 at 8:59 PM, Bhupendra Dubey bhupendra@gmail.comwrote: Sort each of the word and form a trie , if any words comes again you get one sch case. On Wed, Jul 18, 2012 at 2:12 PM, vindhya chhabra vindhyachha...@gmail.com wrote: yes,sorry count sort will be O(n) so better.thanks On Wed, Jul 18, 2012 at 1:43 PM, saurabh singh saurab...@gmail.comwrote: ^sorting a string would be o(n^2logn) if u use q.sort.count sort would be better. Saurabh Singh B.Tech (Computer Science) MNNIT blog:geekinessthecoolway.blogspot.com On Wed, Jul 18, 2012 at 1:08 PM, vindhya chhabra vindhyachha...@gmail.com wrote: sort the list,sort the word(use quick sort(nlogn time))- and den search using binary search(logn time) or we can evn do by hashing-hash the word,den for every word keep decreasing the counter,if the hash array is zero ,anagram,else reset the hash array for given input for the checking the next word. On Wed, Jul 18, 2012 at 2:07 AM, Navin Kumar algorithm.i...@gmail.comwrote: Assuming a preexisting list of 100 words, how would you efficiently see if a word received from input is an anagram of any of the 100 words? -- 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/-/5kuxjymYEc4J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- 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. -- Thanks regards Bhupendra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Abhishek Sharma Under-Graduate Student, PEC University of Technology -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Anagram problem
@Abhishek +1 On Wed, Jul 18, 2012 at 11:19 PM, Abhishek Sharma abhi120...@gmail.comwrote: sort each word in the list,then sort the whole list. Now,sort the input word(string). and then use binary search to find the word. On Wed, Jul 18, 2012 at 8:59 PM, Bhupendra Dubey bhupendra@gmail.comwrote: Sort each of the word and form a trie , if any words comes again you get one sch case. On Wed, Jul 18, 2012 at 2:12 PM, vindhya chhabra vindhyachha...@gmail.com wrote: yes,sorry count sort will be O(n) so better.thanks On Wed, Jul 18, 2012 at 1:43 PM, saurabh singh saurab...@gmail.comwrote: ^sorting a string would be o(n^2logn) if u use q.sort.count sort would be better. Saurabh Singh B.Tech (Computer Science) MNNIT blog:geekinessthecoolway.blogspot.com On Wed, Jul 18, 2012 at 1:08 PM, vindhya chhabra vindhyachha...@gmail.com wrote: sort the list,sort the word(use quick sort(nlogn time))- and den search using binary search(logn time) or we can evn do by hashing-hash the word,den for every word keep decreasing the counter,if the hash array is zero ,anagram,else reset the hash array for given input for the checking the next word. On Wed, Jul 18, 2012 at 2:07 AM, Navin Kumar algorithm.i...@gmail.com wrote: Assuming a preexisting list of 100 words, how would you efficiently see if a word received from input is an anagram of any of the 100 words? -- 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/-/5kuxjymYEc4J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- 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. -- Thanks regards Bhupendra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Abhishek Sharma Under-Graduate Student, PEC University of Technology -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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.