subin-shk / DSA-in-any-language

Add DSA solutions in any language.
0 stars 6 forks source link

Added the code of Greedy Algorithms #6

Closed KunjMaheshwari closed 1 week ago

KunjMaheshwari commented 1 week ago

๐Ÿš€ Greedy Algorithms in Java This PR introduces a set of Greedy Algorithms implemented in Java, designed to solve optimization problems by making locally optimal choices at each step. The following algorithms have been implemented, with a focus on clarity, efficiency, and scalability:

Activity Selection Problem: Determines the maximum number of activities that can be performed without overlapping, using a sorted approach. Fractional Knapsack Problem: Implements the fractional knapsack solution by maximizing the value-to-weight ratio. Huffman Encoding: Constructs an optimal prefix code using greedy techniques to minimize the average encoding length. Job Sequencing Problem: Finds the optimal job scheduling to maximize profit when each job has a deadline. Minimum Coins Problem: Provides a solution to determine the minimum number of coins required to make a specific amount of change.

๐Ÿ“ Key Highlights: Efficient Algorithms: Time complexity has been minimized where possible, leveraging sorting techniques and heap-based data structures for performance. Modular Code: Each algorithm is implemented as an independent module for ease of testing and integration. Extensive Documentation: Inline comments and Javadoc annotations have been added to explain the logic, assumptions, and edge case handling for each algorithm. Test Cases: Comprehensive test cases included to validate different scenarios, from basic functionality to edge cases.

๐Ÿ’ก Why Greedy Algorithms? Greedy algorithms are a powerful tool for solving optimization problems, where the local optimal solutions lead to a global optimum. This PR adds foundational algorithms that can be extended and modified for more complex use cases in various domains like scheduling, compression, and resource allocation.

KunjMaheshwari commented 1 week ago

Iโ€™m excited to submit my first-ever open-source contribution for Hacktoberfest, which includes implementations of key Java sorting algorithms with clean code, detailed documentation, and tests. Iโ€™d be grateful if you could review and merge my PR, and Iโ€™m open to any feedback for improvement.

Please can you add Hactoberfest labels in my pull request so that It will be accepted on the Hactoberfest Profile. @subin-shk