|
| 1 | +import { Helper } from "src/app/helper/helper" |
| 2 | + |
| 3 | +const greedyData = { |
| 4 | + defination: `A greedy algorithm is an approach for solving a problem by selecting the best option available at the moment. |
| 5 | + It doesn't worry whether the current best result will bring the overall optimal result. <br> |
| 6 | + The algorithm never reverses the earlier decision even if the choice is wrong. It works in a top-down approach. |
| 7 | + <br> |
| 8 | + This algorithm may not produce the best result for all the problems. It's because it always goes for the local best |
| 9 | + choice to produce the global best result. |
| 10 | + `, |
| 11 | + example: 'assets/ds-image/greedy.jpg', |
| 12 | + properties:[ |
| 13 | + `<b>Greedy Choice Property:</b> If an optimal solution to the problem can be found by choosing the best choice at |
| 14 | + each step without reconsidering the previous steps once chosen, the problem can be solved using a greedy approach. |
| 15 | + This property is called greedy choice property.`, |
| 16 | + `<b>Optimal Substructure:</b> If the optimal overall solution to the problem corresponds to the optimal solution to |
| 17 | + its subproblems, then the problem can be solved using a greedy approach. This property is called optimal substructure.` |
| 18 | + ], |
| 19 | + components:[ |
| 20 | + `<b>Candidate set:</b> A solution that is created from the set is known as a candidate set.`, |
| 21 | + `<b>Selection function:</b> This function is used to choose the candidate or subset which can be added in the solution.`, |
| 22 | + `<b>Feasibility function:</b> A function that is used to determine whether the candidate or subset can be used to contribute |
| 23 | + to the solution or not.`, |
| 24 | + `<b>Objective function:</b> A function is used to assign the value to the solution or the partial solution.`, |
| 25 | + `<b>Solution function:</b> This function is used to intimate whether the complete function has been reached or not.`, |
| 26 | + ], |
| 27 | + algorithm:[ |
| 28 | + `To begin with, the solution set (containing answers) is empty.`, |
| 29 | + `At each step, an item is added to the solution set until a solution is reached.`, |
| 30 | + `If the solution set is feasible, the current item is kept.`, |
| 31 | + `Else, the item is rejected and never considered again.` |
| 32 | + ], |
| 33 | + applications:[ |
| 34 | + `Selection Sort`, |
| 35 | + `Fractional knapsack Problem`, |
| 36 | + `Minimum Spanning Tree(Prim's, Kruskal's,)`, |
| 37 | + `Single-Source Shortest Path Problem`, |
| 38 | + `Job Scheduling Problem`, |
| 39 | + `Huffman Coding`, |
| 40 | + `Ford-Fulkerson Algorithm` |
| 41 | + ], |
| 42 | + advantages: [ |
| 43 | + `The algorithm is easier to describe.`, |
| 44 | + `This algorithm can perform better than other algorithms (but, not in all cases).` |
| 45 | + ], |
| 46 | + disadvantage: [ |
| 47 | + `As mentioned earlier, the greedy algorithm doesn't always produce the optimal solution. |
| 48 | + This is the major disadvantage of the algorithm` |
| 49 | + ] |
| 50 | +} |
| 51 | + |
| 52 | +export const greedyMetaData = { |
| 53 | + defination: Helper.setHeader(greedyData.defination), |
| 54 | + example: Helper.setExampleImage('Greedy Approach', greedyData.example), |
| 55 | + properties: Helper.setListwithTitleHtml('Properties of Greedy Algorithm', greedyData.properties), |
| 56 | + components: Helper.setListwithTitleHtml('Components of Greedy Algorithm', greedyData.components), |
| 57 | + algorithm: Helper.setListwithTitleHtml('Greedy Algorithm', greedyData.algorithm), |
| 58 | + applications: Helper.setListwithTitleHtml('Applications of Greedy Algorithm', greedyData.applications), |
| 59 | + advantage: Helper.setListwithTitleHtml('Advantages of Greedy Algorithm', greedyData.advantages), |
| 60 | + disadvantage: Helper.setListwithTitleHtml('Disadvantages of Greedy Algorithm', greedyData.disadvantage), |
| 61 | + |
| 62 | +} |
0 commit comments