Sunday, July 27, 2014
What is 0/1 Knapsack problem ?
The knapsack or rucksack problem is a problem in combinatorial optimization. Here there are a set of items(n) which has a profit value(v) and weight(w). There is a bag which has a maximum capacity(W). Now the problem is to fill the bag with the following restrictions :
1. You can either choose an item completely or reject it. (0 or 1)
2. The total weight of bag must not exceed its maximum capacity W. i.e. (Sum of w[i]) <= W
3. The total value or profit of items chosen must be maximum. i.e. Sum of p[i] is maximum
where 0 < i <=n.
How to solve 0/1 Knapsack problem in Java ?
Step1: Structure: Characterize the structure of an optimal solution.
– Decompose the problem into smaller problems, and ﬁnd a relation between the structure of the optimal solution of the original problem and the solutions of the smaller problems.
Tuesday, July 22, 2014
here we ahve shown how to convert an infix expression to postfix using stack. Here we will just try to do the reverse. Here in our example we will be able to convert any postfix expression to infix irrespective of the operators. A number of parenthesis may be generated extra which were not there in original infix expression. The parenthesis that may be generated extra will have no impact on actual expression, they are just for better understanding. The process of postfix to infix conversion is summarised below -
Saturday, July 12, 2014
Saturday, July 5, 2014
After all necessary setups, the first thing you will have to do is to write a JPA entity. Many IDE like Eclipse can automatically create it, but we will show how to write it and what are the steps. You must have seen the JavaBean style classes. Here our first task is to write a class in that style only. Next we will make some modifications to make it a JPA entity.
Today I will show you how you can implement Bankers algorithm in Java. The Banker's algorithm is a resource allocation and deadlock a...
------------------------- UPDATE ------------------------- I have updated the code on request of some followers so that they can directly...
--------------------UPDATE------------------- I have updated my post so that now it can detect IE 11. This modification was necessary as t...
Today I am going to show how to convert a postfix expression to an infix expression using stack in Java. In an earlier post here we ...
Today in this article I will tell you how to convert an infix expression to postfix expression using stack. This is an important applicat...
Today I am going to post a program that will be able to produce all the mColorings of a given graph G. What is mColoring : The problem st...
Today I am going to show you how you can generate and validate captcha. A CAPTCHA (an acronym for "Completely Automated Public Turin...
Today I will show you how to do 256bits AES encryption and decryption of a file in Java. You can write codes for AES - 128bits without d...
- ▼ July ( 4 )
- ► 2013 ( 28 )
- I am a student of BTech Computer Science Engineering from RCCIIT,Kolkata. I am a crazy lover of Java and wants to settle as a Java developer. I have a seven years Java experience with an application developer experience for 2 years. Recently from March 2012 I am a registered S40 app developer for Nokia and has corrected an app of them. I am currently writing blogs to encourage and grow interest in all those who don't know or learning Java.