can anyone suggest some method to show all the permutation of a set of characters 1)recursively, and
2)non-recursively but using stack operation
and i can't use any pre-set function of C++
can anyone suggest some method to show all the permutation of a set of characters 1)recursively, and
2)non-recursively but using stack operation
and i can't use any pre-set function of C++
A starting point: http://cboard.cprogramming.com/searc...earchid=564261.
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
1 - Grab a bunch of magazines, put them in a pile. You have your first permutation.
2 - Move the magazines to another pile by only touching the top magazine. You have your second permutation.
3 - Now, create another pile by touching only the top magazine, but put the first aside and only move to the new pile in the end. You have your third permutation.
4 - Repeat 3 as many times as magazines you have - 1 time (you already did that one). You have a bunch of new permutations.
5 - Repeat 3 but this time it is the second magazine that you move aside.
6 - Do 4 again for the second magazine.
...
repeat 5 and 6 until after you moved aside the last magazine. You have all permutations. ( I think. If you have more, you will find out as you try this test and correct my logic. It's also part of the learning process. Good on you)
Translate that to code.
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.