Go icon indicating copy to clipboard operation
Go copied to clipboard

Add Greedy Algorithms Implementation

Open shyamatripathi opened this issue 3 months ago • 1 comments

What would you like to share?

Add implementations of fundamental greedy algorithms currently missing from the repository.

Algorithms to Implement Activity Selection (max non-overlapping activities)

Fractional Knapsack (max value with divisible items)

Coin Change - Greedy (min coins for amount)

Huffman Coding (optimal prefix codes)

Job Sequencing (max profit with deadlines)

Files Structure:

greedy/ ├── activityselection/ ├── fractionalknapsack/ ├── coinchange/ ├── huffman/ └── jobsequencing/ Each package will include:

Implementation with tests

Proper documentation

Complexity analysis

Extra issue details

I propose adding a comprehensive greedy package containing implementations of fundamental greedy algorithms that are currently missing from the repository.

Algorithms to Implement

Activity Selection Problem: Select maximum number of non-overlapping activities from given start/end times. Files:

greedy/activityselection/activityselection.go

greedy/activityselection/activityselection_test.go

Fractional Knapsack Problem: Maximize total value in knapsack when items can be divided. Files:

greedy/fractionalknapsack/fractionalknapsack.go

greedy/fractionalknapsack/fractionalknapsack_test.go

Coin Change (Greedy Version) Problem: Find minimum coins needed for given amount using greedy approach. Files:

greedy/coinchange/coinchange.go

greedy/coinchange/coinchange_test.go

Huffman Coding Problem: Build optimal prefix codes for data compression. Files:

greedy/huffman/huffman.go

greedy/huffman/huffman_test.go

Job Sequencing Problem: Schedule jobs with deadlines to maximize profit. Files:

greedy/jobsequencing/jobsequencing.go

greedy/jobsequencing/jobsequencing_test.go

Implementation Standards Each algorithm will include:

Clean, documented Go code

Comprehensive test cases (>90% coverage)

Time/Space complexity analysis

Example usage

Follows existing repository patterns

Benefits Completes algorithm coverage

Educational resource

Practical implementations

Ready for production use

I will implement all algorithms following the repository's coding standards and testing requirements.

Additional information

No response

shyamatripathi avatar Oct 29 '25 13:10 shyamatripathi

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Nov 29 '25 00:11 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Dec 07 '25 00:12 github-actions[bot]