Talk:Algorithm
The ip that changed the first paragraph was me, so any comment my way please. Tryx 04:36, 30 November 2007 (UTC)
Please post only simple english. It is very difficult to understand the complex words you have said. "any comment my way please" is not at all simple. Thank you.
Sorting by numbers
changeI think the algorithm sorting by numbers does not work. You go through the all cards one time and the biggest card is on the top of stack B but after that all it does is the cards under the top one just go backwards, like 4213 4312 4213 4312 forever. If you want it to work, every time when all the cards are in stack B you have to take off the card from on top of stack B and put it in stack C or something and then you move stack B to stack A. Then when all the cards are in stack C they are sorted. Teenly 21:16, 5 March 2009 (UTC)
- Thanks, Teenly; this is in fact an error; I need think about solving this. If you start with 4213 (top of stack at the left) you end up with 4312 at the end of the first run (4-42-412-4312 on Stack B); a second run gives you 4213 at the end (4-43-413-4213) - which is what we started out at the beginning. I'll think about it, and get back. --Eptalon (talk) 22:27, 5 March 2009 (UTC)
- Following this discovery, I have replaced the Sorting by numbers algorithm. I hope it works now. --Eptalon (talk) 09:01, 6 March 2009 (UTC)
After it compares card 1 and card 2 then step 7 says look at the next card in the stack. That is card 3 so it compares card 3 and card 4 next but it did not compare card 2 and card 3 first like in the example. I looked in the history and you did so much work on this article. I hope it is easy to fix. The example is easy to understand. Teenly 21:50, 7 March 2009 (UTC)
- Your problem is that the first algorithm (bubble sort) needs to keep track of a position; this position is only changed in step 3; As you can see in the example below, you will travel with the card through the stack as long as the next card has a lower number. You will also see that with 4 steps instead of 9, the second algorithm is much faster--Eptalon (talk) 22:56, 7 March 2009 (UTC)
I have also added a third algorithm; the second and the third algorithm are of the kind of those used for sorting numbers in real life.--Eptalon (talk) 01:02, 8 March 2009 (UTC)
- The article looks great! The animations are neat. And Happy Eptalon's Day! Teenly 18:15, 8 March 2009 (UTC)
Example
changeI am taking the example you had before, and I will go through it with both algorithms. As on the main page, the cards being compared are bold, the top of the stack is on the left, to show where I am at, I will use p after the card; different stacks are separated by ';'
Algorithm 1 (Bubble sort)
change(position - p, swapped cards -s)
- First run
- 4p 2 1 3 -> 2 4 1 3 (s)
- 2 4p 1 3 -> 2 1 4 3 (s)
- 2 1 4p 3 -> 2 1 3 4 (s)
- Second run
- 2p 1 3 4 -> 1 2 3 4 (s)
- 1 2p 3 4 -> 1 2 3 4 (s)
- 1 2 3p 4 -> 1 2 3 4 (s)
- Third run
- 1p 2 3 4 -> 1 2 3 4
- 1 2p 3 4 -> 1 2 3 4
- 1 2 3p 4 -> 1 2 3 4
- Done
Algorithm 2
change(';' to separate stacks)
- 4213 -> 42; 13
- 42;13 -> 4;2;1;3
- 4;2;1;3 ->24;13 (note: go through merging two stacks together)
- 24;13 ->1234
- Done
This page might not have the most relevant and general information
changeIt seems like this page is more a series of examples of algorithms, rather than an explanation of different kinds of algorithms and what they could be used for. I think for someone who is looking to learn some general things about algorithms, this might not be the best kind of information to know.
These examples seem like they would belong best in an article about sorting algorithms.
I'm not great with Wikipedia etiquette, but I'm very passionate about algorithms - I'd be willing to help restructure the page a bit, is that okay?