Thanks for the replies Peter, and Oisin. I will try to make high level 
pseudo code for the algorithm, and see if I can break the algorithm into 
manageable cards.

Aditya

On Friday, January 29, 2016 at 11:28:24 PM UTC+5:30, Oisín Mac Fhearaí 
wrote:
>
> I'd agree with Peter in general for this kind of stuff; it's probably 
> better to rewrite the code from scratch a couple of times (maybe a few 
> different ways), and play some code golf or whatnot.
>
> However if you want to use SRS, I'd advise to reduce the code to higher 
> level pseudocode (i.e. not "for(i = s.size()-1; i >= 0; i--) if(P[i] > max) 
> max = P[i]", but "m = max(node weight)" or something).
> Then use cloze deletion on each line of the pseudocode. But I'd try to 
> reduce it to less than 10 lines of pseudocode per card - ideally your 
> pseudocode would be the minimal information necessary to remind you how to 
> reconstruct the algorithm.
>
> O
>
> On 29 January 2016 at 17:45, Peter Bienstman <[email protected] 
> <javascript:>> wrote:
>
>> Hi,
>>
>> Not sure spaced repetition is the best tool for this. Personally, I would 
>> try implementing the algorithm from scratch to try and internalise it.
>>
>> But perhaps people have other suggestions.
>>
>> Cheers,
>>
>> Peter
>>
>>
>> On Friday, 29 January 2016 18:41:32 UTC+1, Aditya BSRK wrote:
>>>
>>> Hi,
>>> I am an on and off user of spaced repetition software. I have been 
>>> considering on how best to use Mnemosyne to remember code for algorithms.
>>> For example, take the algorithm for finding the least common ancestor 
>>> <https://www.topcoder.com/community/data-science/data-science-tutorials/range-minimum-query-and-lowest-common-ancestor/#Another%20easy%20solution%20in%20O(N%20logN,%20O(logN)>
>>>  
>>> of two nodes in a tree. Lifting the code from topcoder:
>>>
>>>  void process3(int N, int T[MAXN], int P[MAXN][LOGMAXN])
>>>   {
>>>       int i, j;
>>>    
>>>   //we initialize every element in P with -1
>>>       for (i = 0; i < N; i++)
>>>           for (j = 0; 1 << j < N; j++)
>>>               P[i][j] = -1;
>>>    
>>>   //the first ancestor of every node i is T[i]
>>>       for (i = 0; i < N; i++)
>>>           P[i][0] = T[i];
>>>    
>>>   //bottom up dynamic programing
>>>       for (j = 1; 1 << j < N; j++)
>>>          for (i = 0; i < N; i++)
>>>              if (P[i][j - 1] != -1)
>>>                  P[i][j] = P[P[i][j - 1]][j - 1];
>>>   }
>>>
>>>  int query(int N, int P[MAXN][LOGMAXN], int T[MAXN], 
>>>   int L[MAXN], int p, int q)
>>>   {
>>>       int tmp, log, i;
>>>    
>>>   //if p is situated on a higher level than q then we swap them
>>>       if (L[p] < L[q])
>>>           tmp = p, p = q, q = tmp;
>>>   
>>>   //we compute the value of [log(L[p)]
>>>       for (log = 1; 1 << log <= L[p]; log++);
>>>       log--;
>>>    
>>>   //we find the ancestor of node p situated on the same level
>>>   //with q using the values in P
>>>       for (i = log; i >= 0; i--)
>>>           if (L[p] - (1 << i) >= L[q])
>>>               p = P[p][i];
>>>    
>>>       if (p == q)
>>>           return p;
>>>    
>>>   //we compute LCA(p, q) using the values in P
>>>       for (i = log; i >= 0; i--)
>>>           if (P[p][i] != -1 && P[p][i] != P[q][i])
>>>               p = P[p][i], q = P[q][i];
>>>    
>>>       return T[p];
>>>   }
>>>
>>> This is a fairly large algorithm, with some intense logic behind it. 
>>> What is the best way to be able to recall it on the fly when I need it?
>>>
>>> Thanks,
>>> Aditya
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "mnemosyne-proj-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/mnemosyne-proj-users/c1576a3f-304c-44c5-8597-4a70f8cb384c%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/mnemosyne-proj-users/c1576a3f-304c-44c5-8597-4a70f8cb384c%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"mnemosyne-proj-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mnemosyne-proj-users/da0ff520-0d12-4d3b-aed8-dc228bc75183%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to