Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Job Sequencing Algorithm in C++ #2882

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sneha0099
Copy link

@sneha0099 sneha0099 commented Oct 25, 2024

Description of Change

Closes #2881

Implemented the Job Sequencing Algorithm using a greedy approach to maximize profit by scheduling jobs within their respective deadlines. The jobSequencing() function arranges jobs based on the highest profit within the available time slots. Example input and expected output have been included in comments for clarity.

Checklist

  • Added description of change
  • Added file name matches File name guidelines
  • Added tests and example, test must pass
  • Added documentation so that the program is self-explanatory and educational - Doxygen guidelines
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Notes:
This PR adds the Job Sequencing Algorithm, which is an essential greedy algorithm for maximizing profit from job scheduling.

- Implemented the Job Sequencing Algorithm using a greedy approach to maximize profit by scheduling jobs within their respective deadlines.
- Added `jobSequencing()` function which takes an array of jobs (each with an ID, deadline, and profit) and schedules them based on highest profit within the available deadlines.
- The algorithm sorts jobs by profit and iteratively assigns them to the latest available slots, aiming to maximize the total profit.
- Included comments to explain the structure of the algorithm, sorting, and scheduling logic for clarity.

Example Input:
  Jobs = { {'a', 2, 100}, {'b', 1, 19}, {'c', 2, 27}, {'d', 1, 25}, {'e', 3, 15} }

Expected Output:
  Job sequence for maximum profit: a c e 
  Total Profit: 142

This implementation improves the repository by adding an essential scheduling algorithm, providing learners with a practical example of greedy algorithms in C++.
Copy link
Contributor

This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Author has not responded to the comments for over 2 weeks label Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Author has not responded to the comments for over 2 weeks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Job Sequencing Algorithm in c++
1 participant