User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Assembly section within the Software Development category of DaniWeb, a massive community of 427,497 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,427 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Assembly advertiser: Programming Forums
Views: 1596 | Replies: 2
Reply
Join Date: Sep 2006
Posts: 5
Reputation: 2bejiw is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
2bejiw's Avatar
2bejiw 2bejiw is offline Offline
Newbie Poster

Question I have problem about Knapsack in ASM

  #1  
Sep 20th, 2006
The knapsack problem

I try to write about this problem but i can't ...

This is a problem thai i have ..

Suppose you want your knapsack to weigh exactly 20 pounds,
and you have only five item, with weight 11,8,7,6,5 pounds.
For small number of items, humans are preety good at solving this problem by inspection.
So you can probably figure out that only the 8,7,5 combination of items adds up to 20.

....................................................................................................

Easy to understand is write about how to add item equal to 20
using ASM lan.
...................................................................................................
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2006
Posts: 5
Reputation: 2bejiw is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
2bejiw's Avatar
2bejiw 2bejiw is offline Offline
Newbie Poster

Re: I have problem about Knapsack in ASM

  #2  
Sep 22nd, 2006
i have java code for that project

How can i change from java to ASM

public class Knapsack {

public static void main(String[] args) {

int[] x = { 11, 8, 7, 6, 5 }; // descendingly sorted inputs
int target = 20; // our target
boolean[] y = null; // y[i] will be true if x[i] is selected
boolean foundAnswer = false;
int sum = 0;
abc: for (int i = 0; i < x.length; i++) {
y = new boolean[x.length]; // all y(s) will be set default to 'false'
sum = x[i];
y[i] = true; // x[i] is selected
for (int j = i + 1; j < x.length; j++) {
if (sum + x[j] <= target) {
sum += x[j];
y[j] = true;
}

if (sum == target) {
foundAnswer = true; // now we found the answer.
break abc; // break out from outer most for loop
}
}
}
if (foundAnswer) {
System.out.println("Found Answer");
for (int i = 0; i < x.length; i++) {
if (y[i]) {
System.out.println(x[i]);
}
}
} else {
System.out.println("No Answer Found!!");
}
}
}

=============================================
Reply With Quote  
Join Date: Sep 2006
Posts: 1
Reputation: Achellis is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Achellis Achellis is offline Offline
Newbie Poster

Re: I have problem about Knapsack in ASM

  #3  
Sep 25th, 2006
i think u should ask AJ VasaKa na cuz she can help u
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Assembly Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Assembly Forum

All times are GMT -4. The time now is 7:06 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC