A partition of a positive integer n is a sequence of positive integers that sum to n. Write an algorithm in psedocode and then implement the algorithm (in C) to print all non-increasing partitions of n.
eg. If n=4
4
3 1
2 2
2 1 1
1 1 1 1
|
Team Leader
|
![]() |
| 25Aug2007,14:44 | #2 |
|
Well, look at your example. There's a pattern there. Use that to devise your algorithm. This is your problem to solve -- it's how you learn. We're here to help you with the code problems.
madhu_
like this
|
|
Light Poster
|
|
| 25Aug2007,15:24 | #3 |
|
Quote:
Originally Posted by DaWei
madhu_
like this
|
|
Team Leader
|
![]() |
| 25Aug2007,15:30 | #4 |
|
Explain how you would go about solving this problem, mentally. We'll go from there.
|
|
Light Poster
|
|
| 25Aug2007,15:39 | #5 |
|
Quote:
Originally Posted by DaWei 5 4 1 (4+1 = 5) 3 2 (3+2 = 5) 3 1 1 (3+1+1 =5) 2 1 1 1 (2+1+1+1 = 5) 1 1 1 1 1 (1+1+1+1+1 = 5) thats how we can calculate it ...i think we have to use recursive function |
|
Go4Expert Founder
|
![]() |
| 25Aug2007,22:25 | #6 |
|
Do you have any algorithm in mind to go about it?
madhu_
like this
|
|
Light Poster
|
|
| 25Aug2007,22:29 | #7 |
|
Quote:
Originally Posted by shabbir |
|
Go4Expert Founder
|
![]() |
| 25Aug2007,22:52 | #8 |
|
Quote:
Originally Posted by isurues |
|
Light Poster
|
|
| 25Aug2007,22:57 | #9 |
|
Quote:
Originally Posted by shabbir |
|
Light Poster
|
|
| 25Aug2007,22:59 | #10 |
|
Quote:
Originally Posted by shabbir |


