# GreedyNotes

### [Activity Selection Problem](https://github.com/AyushKumar123456789/DSA/blob/master/Greedy/1.Activity_Selection.cpp)

* **Problem**: Given a set of activities, each with a start and finish time, select the maximum number of activities that can be performed by a single person, assuming that a person can only work on a single activity at a time.
* **Approach**: Greedy
* **Algorithm**:
  1. Sort the activities based on their finish time.
  2. Select the first activity.
  3. For each remaining activity, if the start time of the activity is greater than or equal to the finish time of the last selected activity, select the activity.

### [Job Sequencing Problem](https://github.com/AyushKumar123456789/DSA/blob/master/Greedy/2.JobSequencing.cpp)

* **Problem**: Given a set of jobs, each with a deadline and profit, select the maximum profit subset of jobs that can be completed within their deadlines.
* **Approach**: Greedy
* **Algorithm**:
  1. Sort the jobs based on their profit in descending order.
  2. For each job, starting from the job with the highest profit, assign the job to the latest possible slot before its deadline.

### [Huffman Coding](https://github.com/AyushKumar123456789/DSA/blob/master/Greedy/3.HuffmanCoding.cpp)

* **Problem**: Given a set of characters and their frequencies, construct a binary tree such that the sum of the depths of all the characters is minimized.
* **Approach**: Greedy
* **Algorithm**:
  1. Create a min-heap of characters based on their frequencies.
  2. Extract the two characters with the lowest frequencies from the heap.
  3. Create a new internal node with the two characters as children and the sum of their frequencies as the frequency.
  4. Insert the new node back into the heap.
  5. Repeat steps 2-4 until only one node remains in the heap.

### \[Fractional Knapsack Problem]


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ayushkumar-21je0209s-organizatio.gitbook.io/untitled/greedy/greedynotes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
