Skip to content

shahoodrehan/Fractional-Knapsack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Knapsack Algorithm Implementation in C# WinForms

Introduction

An implementation of the Knapsack algorithm using C# WinForms. Given a set of products with their respective values and profits, this project utilizes the Knapsack algorithm to find the optimal solution for maximizing profits while adhering to a given weight constraint. The project is implemented in C# and is designed to be user-friendly by utilizing a WinForms interface.

Implementation

The project is implemented in C# and utilizes a WinForms interface to take input from the user. The user is prompted to input a set of products, along with their respective values and weights. The program then utilizes the Knapsack algorithm to find the optimal solution for maximizing profits while adhering to the given weight constraint.

The project includes several classes, including a "Product" class, which stores the properties of each product (name, value, weight), and a "Knapsack" class, which implements the Knapsack algorithm and contains the logic for finding the optimal solution. The main form of the program, "Form1", uses these classes to take input from the user, run the algorithm, and display the results.

The project also includes several methods like, validate inputs, check user inputs are valid or not, run knapsack algorithm, display result, etc.

How to use

  • Open the project in Visual Studio and run the program.
  • Input the number of products you wish to include in the knapsack.
  • Input the name, value, and weight of each product.
  • Input the weight constraint for the knapsack.
  • Click the Calculate button to run the Knapsack algorithm and find the optimal solution.
  • The results, including the selected items and their total value, will be displayed on the screen.

Conclusion

This project is a great resource for anyone looking to gain a deeper understanding of the Knapsack algorithm and its applications in DSA, as well as for those interested in learning about C# and WinForms development. The user-friendly interface and implementation of the Knapsack algorithm make it an excellent tool for learning and experimentation.

Releases

No releases published

Packages

No packages published

Languages