Open Source Contribution - Release 0.2.2

Contributing to C_plus_plus_Algos

Image result for algorithms picture

C_plus_plus_Algos is a recently created project on Github (targeting Hacktoberfest) that attempts to accumulate code examples for different algorithms and problems in C++. So far the project has done a great job of accumulating different types of sorts in C++ (linear, merge, radix, bubble... sorts). However, since this is a new project, it is lacking many other algorithms and famous problems in C++. In order to help a new project develop further, I decided to contribute a well known Knapsack problem and a way to solve this problem in C++. 

Hacktoberfest 2018

This year I am participating in Hacktoberfest. Throughout the month of October, I will need to make 5 pull requests with contributions to one or more projects on Github. This is my second contribution to Hacktoberfest and I came across C_plus_plus_Algos project on Github for this contribution. I thought that it would be a good experience for me to get involved in one of the earliest stages of a project in order to help them develop throughout the rest of the year.

For my third contribution of Hacktoberfest, I've filed an issue to refactor the structure of the C_plus_plus_Algos. If approved by the creator, I think it will be very helpful to the project. Right now C_plus_plus_Algos does not have rules for file naming and contributors don't follow a specific structure. Refactoring this repo will make it less confusing for new comers to use this project.

Throughout this Hacktoberfest I'm trying to find different ways to contribute to the open-source community. I've already explored non-code contributions and how they can be useful. I also explored contributing to start up project. For the fourth and fifth pull requests I will try to explore ways to contribute to bigger, more sophisticated coding project. This will allow me to experience the difficulties of contributing to big projects and talk about these challenges.


My Contribution


The creator of C_plus_plus_Algos produced a few simple issues to get people involved in his project and populate it with algorithms and problems. In order to contribute to this project, I decided to research one of the popular problems and C++ solutions to this problem. I came across the Knapsack Problem and I've seen many variations of this problem in different situations.

Some of the situations where I've seen a variation of this problem were:


  • A question on a test for a programming course
  • A question during a job interview. 

Therefore, I thought that an explanation of this problem and a solution would be extremely useful to this project and the people that will be looking for this project to help them solve this problem in real life situations.




Description of the Knapsack Problem

 Taking value and weight of items, and placing them in a knapsack of a certain
 capacity to get the maximum total value in the knapsack. Find a maximum value subset that
 can be placed into the knapsack such that the total weight of these items is not higher than
 the total weight capacity of the knapsack.

 Example:

 int val[] = {60, 100, 120};
 int wt[] = {10, 20, 30};
 int W = 50;

 The subset that will achieve the maximum weight of 50 (without going over this number) and
 achieving the highest value would be two items with the weight of 20 and 30, and the value
 of 100 and 120 respectively. Therefore, the maximum value that can be stored in the knapsack
 is 220 (100 + 120).

C++ Solution to the Problem can be found in my pull request that I link below.





Link to the issue:

Link to the pull request:


List of things that I added to C_plus_plus_Algos:
  • Added Knapsack Problem to the Dynamic Programming folder.
    • A description and some background of the problem to help understand the problem.
    • Code solution that provides a solution to solve the Knapsack problem.
  • Added myself to the list of contributors.
  • Modified README file to include Dynamic Programming topic (with coin change problem and knapsack problem)

Conclusion



It feels nice to start contributing to a project that is in beginning stages because it feels like your contribution is more impactful than contributing to a massive 10 year old project with thousands of contributors. Furthermore, a great way to help your community and the people in your field is contributing to a project that once it's developed would be a helpful tool to programmers worldwide.


Comments

Popular posts from this blog

First Enhancement in Pandas

Working with Incomplete MultiIndex keys in Pandas

Progress in Open Source