1. For first question trie of given word will be best option.
Space complexity O(total length of words) (worst case)
Time complexity O(T) . T length of input text (Newspaper)
2. consider it to be a 4 digit number ABCD . Find maximum Most
significant digit say it is C , and out of these nos find maximum value of
next digit say A and so on . Suppose Final no. is CADB
Now next highest permutation will be the no. just greater than this and
made of these digits . This is easy.
On Wed, Jul 4, 2012 at 5:17 PM, Bhupendra Dubey <[email protected]>wrote:
> Consider trees:
>
> 1 3
> 2 3 2
> 1
> pre order traversal is same still (1 , 2 ,3) even though ist tree doesn't
> satisfy the criteria . So I don't think it can be determined.
>
> On Wed, Jul 4, 2012 at 4:16 PM, Ashish Goel <[email protected]> wrote:
>
>> Q4
>>
>>
>> vector<String> prefix;
>> prefix[0]=NULL;
>> prefixCount =1;
>> for (int i=0;i<n;i++)
>> for (int j=0;j<n;j++)
>> for (int k=0; k<prefixCount;k++)
>> {
>> if (visited[i][j]) continue;
>> visited[i][j] = true;
>> String s=prefix[k]+a[i][j];
>> if (isWord(s) { printWord(s); prefix[k]=s; continue;}
>> else if isPrefix(s) prefix[prefixCount++] = s;
>> else removePrefix(prefix[k], prefixCount);
>> prefix[prefixCount++] = String(a[i][j];
>> }
>> Best Regards
>> Ashish Goel
>> "Think positive and find fuel in failure"
>> +919985813081
>> +919966006652
>>
>>
>> On Wed, Jul 4, 2012 at 4:13 PM, Ashish Goel <[email protected]> wrote:
>>
>>> 1. inverted hasp map
>>> 2. not clear
>>> 3. VLR, how do you identify end of L and start of R, question incomplete
>>> 4. One problem: consider
>>>
>>> .......
>>> a b...
>>> c d...
>>> .......
>>>
>>> if ab is a prefix, can aba be another prefix, i would assume so. But if
>>> that is true, i am not sure if this program will come to an end.
>>> vector<String> prefix;
>>> prefix[0]=NULL;
>>> prefixCount =1;
>>> for (int i=0;i<n;i++)
>>> for (int j=0;j<n;j++)
>>> for (int k=0; k<prefixCount;k++)
>>> {
>>> String s=prefix[k]+a[i][j];
>>> if (isWord(s) { printWord(s); prefix[k]=s; continue;}
>>> else if isPrefix(s) prefix[prefixCount++] = s;
>>> else removePrefix(prefix[k], prefixCount);
>>> prefix[prefixCount++] = String(a[i][j];
>>> }
>>> Best Regards
>>> Ashish Goel
>>> "Think positive and find fuel in failure"
>>> +919985813081
>>> +919966006652
>>>
>>>
>>>
>>> On Wed, Jul 4, 2012 at 12:22 PM, Decipher <[email protected]>wrote:
>>>
>>>> Find the next higher number in set of permutations of a given number
>>>
>>>
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Thanks & regards
> Bhupendra
>
>
>
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.