[algogeeks] Re: Dynamic Programming Problem SPOJ-AMR11A

2012-07-18 Thread Bharat Kul Ratan
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

Re: [algogeeks] Anagram problem

2012-07-18 Thread vindhya chhabra
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

Re: [algogeeks] Anagram problem

2012-07-18 Thread saurabh singh
^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

Re: [algogeeks] Anagram problem

2012-07-18 Thread vindhya chhabra
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

[algogeeks]

2012-07-18 Thread vindhya chhabra
#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 --

Re: [algogeeks]

2012-07-18 Thread vindhya chhabra
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);

Re: [algogeeks]

2012-07-18 Thread Sanjay Rajpal
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

Re: [algogeeks] Anagram problem

2012-07-18 Thread Bhupendra Dubey
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:

Re: [algogeeks] Anagram problem

2012-07-18 Thread Abhishek Sharma
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

Re: [algogeeks] Anagram problem

2012-07-18 Thread Navin Kumar
@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