help me to solve this problem

isurues's Avatar, Join Date: Aug 2007
Light Poster
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
0
DaWei's Avatar, Join Date: Dec 2006
Team Leader
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
0
isurues's Avatar, Join Date: Aug 2007
Light Poster
Quote:
Originally Posted by DaWei
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.
if can give me a C coding for this problem
madhu_ like this
0
DaWei's Avatar, Join Date: Dec 2006
Team Leader
Explain how you would go about solving this problem, mentally. We'll go from there.
0
isurues's Avatar, Join Date: Aug 2007
Light Poster
Quote:
Originally Posted by DaWei
Explain how you would go about solving this problem, mentally. We'll go from there.
Eg n = 5
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
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Do you have any algorithm in mind to go about it?
madhu_ like this
0
isurues's Avatar, Join Date: Aug 2007
Light Poster
Quote:
Originally Posted by shabbir
Do you have any algorithm in mind to go about it?
i dont have any idea...
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Quote:
Originally Posted by isurues
i dont have any idea...
As I can see its just a number split into numbers which sum up to the inputed number till all become one.
0
isurues's Avatar, Join Date: Aug 2007
Light Poster
Quote:
Originally Posted by shabbir
As I can see its just a number split into numbers which sum up to the inputed number till all become one.
ya thats according to the input n
0
isurues's Avatar, Join Date: Aug 2007
Light Poster
Quote:
Originally Posted by shabbir
As I can see its just a number split into numbers which sum up to the inputed number till all become one.
Ya need all the possible number which v can split