Click here to Skip to main content
15,949,686 members
Home / Discussions / Algorithms
   

Algorithms

 
QuestionNeed of Decision Tree Implementation Pin
Radiit6-May-10 3:05
Radiit6-May-10 3:05 
Questionfind a sulution! Pin
wbgxx3-May-10 3:59
wbgxx3-May-10 3:59 
AnswerRe: find a sulution! Pin
Kevin Drzycimski3-May-10 4:06
Kevin Drzycimski3-May-10 4:06 
GeneralRe: find a sulution! Pin
wbgxx3-May-10 4:12
wbgxx3-May-10 4:12 
GeneralRe: find a sulution! Pin
Luc Pattyn3-May-10 4:13
sitebuilderLuc Pattyn3-May-10 4:13 
GeneralRe: find a sulution! Pin
wbgxx3-May-10 4:15
wbgxx3-May-10 4:15 
AnswerRe: find a solution! Pin
theCPkid6-May-10 2:21
theCPkid6-May-10 2:21 
GeneralRe: find a solution! [modified] Pin
Radhakrishnan G.18-May-10 3:30
Radhakrishnan G.18-May-10 3:30 
Subset Sum problem
I am pasting an algorithm, got this from a book
Algorithm SumOfSubSet(s,k,r)
// Find all subset of w[1:n] that sum to m. The values of x[j],
// 1 <j<k, have already been determined. s = w[1]*x[1] + ... + w[k-1]*x[k-1]
// and r = w[k] + .. + w[n]. The w[j] are in non decreasing order
// It is assumed that w[1]< m and sum of w[i] > m where i = 1..n
{
	x[k] := 1;
	if( s + w[k] = m ) then Write( x[1:k]); // Subset found
	else if( s + w[k] + w[k+1] <= m ) 
		then SumOfSub( s + w[k], k+1, r-w[k]);
	if( (s+r-w[k] >= m) and (s + w[k+1] <= m )) then
	{
		x[k] := 0;
		SumOfSub( s, k + 1, r - w[k]);
	}
}


s = is the sum to be generated
w is the set with size n,
x is an array and if x[i] is one means <code>ith element in w is in the subset
k is the index of element in w we are examining
r is the remaining sum that can be created from k +1th element to nth item in w

modified on Thursday, May 12, 2011 9:23 AM

GeneralRe: find a solution! Pin
talazz12-May-11 2:53
talazz12-May-11 2:53 
QuestionSimulating movement Pin
Code-o-mat24-Apr-10 5:49
Code-o-mat24-Apr-10 5:49 
AnswerRe: Simulating movement Pin
Software_Developer24-Apr-10 10:12
Software_Developer24-Apr-10 10:12 
GeneralRe: Simulating movement Pin
Code-o-mat24-Apr-10 22:02
Code-o-mat24-Apr-10 22:02 
GeneralRe: Simulating movement Pin
Software_Developer29-Apr-10 6:26
Software_Developer29-Apr-10 6:26 
AnswerRe: Simulating movement Pin
molesworth29-Apr-10 7:11
molesworth29-Apr-10 7:11 
GeneralRe: Simulating movement Pin
Code-o-mat29-Apr-10 9:16
Code-o-mat29-Apr-10 9:16 
QuestionWhats in a name? Pin
Tadeusz Westawic23-Apr-10 2:01
Tadeusz Westawic23-Apr-10 2:01 
QuestionConsole shapes? Pin
venomation18-Apr-10 2:58
venomation18-Apr-10 2:58 
AnswerRe: Console shapes? Pin
Richard MacCutchan18-Apr-10 11:06
mveRichard MacCutchan18-Apr-10 11:06 
AnswerRe: Console shapes? Pin
MikeMarq20-Apr-10 16:33
MikeMarq20-Apr-10 16:33 
Question"Best Fit" Algorithm Request && Teach A Man To Fish Pin
Michael Fritzius17-Apr-10 13:10
professionalMichael Fritzius17-Apr-10 13:10 
AnswerRe: "Best Fit" Algorithm Request && Teach A Man To Fish Pin
Luc Pattyn17-Apr-10 13:45
sitebuilderLuc Pattyn17-Apr-10 13:45 
GeneralRe: "Best Fit" Algorithm Request && Teach A Man To Fish Pin
Radhakrishnan G.18-May-10 3:44
Radhakrishnan G.18-May-10 3:44 
GeneralRe: "Best Fit" Algorithm Request && Teach A Man To Fish Pin
harold aptroot17-Apr-10 14:31
harold aptroot17-Apr-10 14:31 
GeneralRe: "Best Fit" Algorithm Request && Teach A Man To Fish Pin
Som Shekhar17-Apr-10 20:46
Som Shekhar17-Apr-10 20:46 
GeneralRe: "Best Fit" Algorithm Request && Teach A Man To Fish Pin
harold aptroot18-Apr-10 2:01
harold aptroot18-Apr-10 2:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.