I am trying to solve a typical 0/1 knapsack problem (using greedy algorithm). In this problem I have to sort a structure consisting of 2 ints (one that contains the value and their corresponding amount I have to minimize the value to get `n' amounts so i need to sort) I am not able to do so.Please help me out.
Please tell me if there exist any better coding method to solve greedy knapsack problem.
shankhs
0
Junior Poster in Training
Recommended Answers
Jump to PostHave you read : http://en.wikipedia.org/wiki/Knapsack_problem ?
so i need to sort) I am not able to do so.Please help me out.
Why are you not able to do so? Please explain.
Jump to PostI don't understand what for C# code appeares here. There are a lots of insertion (and others) sort C codes in INET. For example, that's one from the excellent tutorial
http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_sorting.aspx#insertvoid jsw_insertion ( Str a[], int n ) { int i; for ( i …
Jump to Postddanbe, I'm indifferent to C#, Java, C++, Ada, Fortran, PL/I or what else codes on C forum for beginners. And shankhs? Let he/she gets the feel of new language (that's C)...
Best regards
All 9 Replies
shankhs
0
Junior Poster in Training
ddanbe
2,724
Professional Procrastinator
Featured Poster
shankhs
0
Junior Poster in Training
ddanbe
2,724
Professional Procrastinator
Featured Poster
ArkM
1,090
Postaholic
ddanbe
2,724
Professional Procrastinator
Featured Poster
ArkM
1,090
Postaholic
ddanbe
commented:
Carry on with the good cause. You're right it was a slip of my tongue, it had to be C here and nothing else.
+2
shankhs
0
Junior Poster in Training
ArkM
1,090
Postaholic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.