@Navin: Okay. Here is a paraphrase. Assume double function random() returns
a uniformly distributed random number >= 0.0 and < 1.0.
read first word from file into string save;
int i = 1
while not EOF
{
read next word from file into string temp;
i++;
if( i * random() < 1.0 )
c
@Dave sir, I didn't get your logic. Can you please elaborate it?
On Sun, Aug 19, 2012 at 4:08 AM, Dave wrote:
> @Navin: Here is the algorithm:
>
> Save the first word.
> For i = 2, 3, ..., n = number of words in the file
> replace the saved word with the i-th word with probability 1/i.
> Whe
@carl- got ur point..but complexity is more..suffix array takes
o(n^2lgn)..considering string comparisons. complexity to build...i already
have o(n^2)..want o(n)..
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send e
concatenate 2 strings adding wild character in between i.e
A="aaa"
B="aaab"
A+B ="aaa$aaab";
wild character is "$";
now create longest prefix table(partial match table) as we do in KMP
algo.
now search for max value after "$" index...in LPS table.
I guess it would work
On Sun, Aug 19, 2012
Oh, I actually read the question totally wrong. I think this idea is
linear, but it's late so I'm not sure.
1. Calculate suffix array and lcp array for the text.
2. Calculate the longest common prefix between your text and the first
entry in your suffix array and initialise a variable called tota
@Carl- I didnt got ur point completely abt Lcp array..can you demonstrate
on the below example...
Example for ababaa
answer shud be -11
suffix array wud be:-
a
aa
abaa
ababaa
baa
and Lcp array would be then
0
1
1
3
0
..correct if wrong..whats next...
--
You received this message because you
Or a suffix tree would work. Pre process it to answer Lowest common
ancestor queries.
On 19 August 2012 21:51, Carl Barton wrote:
> Just calculating the suffix array solves the problem if you do it with the
> LCP array as well. You don't need to 'use' the suffix array so to speak.
>
>
> On 19 Au
Just calculating the suffix array solves the problem if you do it with the
LCP array as well. You don't need to 'use' the suffix array so to speak.
On 19 August 2012 21:45, pankajsingh wrote:
> Is there any O(n) solution this question...I Cleared all the testcases but
> my solution is not O(n) a
what is the rational to do 5*rand5()
why not 4*rand5 or 6 *rand5??
Best Regards
Ashish Goel
"Think positive and find fuel in failure"
+919985813081
+919966006652
On Fri, Jun 22, 2012 at 10:13 AM, Anant Sharma wrote:
>
> The reason why finding a solution to this question is difficult is becaus
@shiva: Nice thinking, man... :)
@Yq Zhang: this similar to base 26 apporch, i have tested below code for
boundary cases ,
0, 26(z), 27(aa), 26*26(yz), 26*27(zz)
public String getColName(int id) {
char ch[] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
'l',
10 matches
Mail list logo