Talk:Stern-Brocot sequence: Difference between revisions

From Rosetta Code
Content added Content deleted
Line 7: Line 7:
==Algorithm used in the C example is different==
==Algorithm used in the C example is different==
The task states a method of calculation that is not used in the current C example. I suggest another example closer to the given algorithm from the task description be used then this C example can be given as an alternative if the algorithm is explained. (I am thinking of starting another task that uses the tree construction and a comparison between the two, but time has not allowed ...). --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 21:47, 8 December 2014 (UTC)
The task states a method of calculation that is not used in the current C example. I suggest another example closer to the given algorithm from the task description be used then this C example can be given as an alternative if the algorithm is explained. (I am thinking of starting another task that uses the tree construction and a comparison between the two, but time has not allowed ...). --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 21:47, 8 December 2014 (UTC)
: There's no real difference here: if you look at the n-th element, you obtain the 2n-1 and 2n-th elements, so you can always find each value backwards. The C program doesn't have a problem printing the first members in sequence, so what's wrong with that? --[[User:Ledrug|Ledrug]] ([[User talk:Ledrug|talk]]) 22:22, 8 December 2014 (UTC)

Revision as of 22:22, 8 December 2014

Finding first occurrences in Python: procedural version

Thanks ‎Ledrug for pointing out a much better way to find first occurrence in the procedural Python example. Once you pointed it out, it became clear why your method worked.

I agree with you keeping it as a comment as well, as it does (at least for me), take another step to see that it works and now we have both methods. (either one of which could be commented). --Paddy3118 (talk) 21:34, 8 December 2014 (UTC)

Algorithm used in the C example is different

The task states a method of calculation that is not used in the current C example. I suggest another example closer to the given algorithm from the task description be used then this C example can be given as an alternative if the algorithm is explained. (I am thinking of starting another task that uses the tree construction and a comparison between the two, but time has not allowed ...). --Paddy3118 (talk) 21:47, 8 December 2014 (UTC)

There's no real difference here: if you look at the n-th element, you obtain the 2n-1 and 2n-th elements, so you can always find each value backwards. The C program doesn't have a problem printing the first members in sequence, so what's wrong with that? --Ledrug (talk) 22:22, 8 December 2014 (UTC)