Please discuss dynamic programming, greedy, and iterative improvement algorithm design technique with an example . Also, compare and contrast these techniques pointing out their advantages and disadvantages.
ANSWER:
Greedy Approach
A greedy algorithm is an algorithm that follows the problem solving heuristic of making the locally optimal choice at each stage with the hope of finding a global optimum. In many problems, a greedy strategy does not in general produce an optimal solution, but nonetheless a greedy heuristic may yield locally optimal solutions that approximate a global optimal solution in a reasonable time.
For example, a greedy strategy for the traveling salesman problem (which is of a high computational complexity) is the following heuristic: "At each step of the journey, visit the nearest unvisited city." This heuristic does not intend to find a best solution, but it terminates in a reasonable number of steps; finding an optimal solution to such a complex problem typically requires unreasonably many steps.
We can make whatever choice seems best at the moment and then solve the sub problems that arise later. The choice made by a greedy algorithm may depend on choices made so far but not on future choices or all the solutions to the sub problem. It iteratively makes one greedy choice after another, reducing each given problem into a smaller one.
Dynamic programming
Dynamic Programming is mainly an optimization over plain recursion. Wherever we see a recursive solution that has repeated calls for same inputs, we can optimize it using Dynamic Programming. The idea behind dynamic programming is quite simple. In general, to solve a given problem, we need to solve different parts of the problem (sub problems), then combine the solutions of the sub problems to reach an overall solution. Often when using a more naive method, many of the sub problems are generated and solved many times.
The dynamic programming approach seeks to solve each sub problem only once, thus reducing the number of computations: once the solution to a given sub problem has been computed, it is stored or "memo-ized": the next time the same solution is needed, it is simply looked up. This approach is especially useful when the number of repeating sub problems grows exponentially as a function of the size of the input.
Difference
Greedy choice property
We can make whatever choice seems best at the moment and then solve the sub problems that arise later. The choice made by a greedy algorithm may depend on choices made so far but not on future choices or all the solutions to the sub problem. It iteratively makes one greedy choice after another, reducing each given problem into a smaller one. In other words, a greedy algorithm never reconsiders its choices.
This is the main difference from dynamic programming, which is exhaustive and is guaranteed to find the solution. After every stage, dynamic programming makes decisions based on all the decisions made in the previous stage, and may reconsider the previous stage's algorithmic path to solution.
For example, let's say that you have to get from point A to point B as fast as possible, in a given city, during rush hour. A dynamic programming algorithm will look into the entire traffic report, looking into all possible combinations of roads you might take, and will only then tell you which way is the fastest. Of course, you might have to wait for a while until the algorithm finishes, and only then can you start driving. The path you will take will be the fastest one (assuming that nothing changed in the external environment).
On the other hand, a greedy algorithm will start you driving immediately and will pick the road that looks the fastest at every intersection. As you can imagine, this strategy might not lead to the fastest arrival time, since you might take some "easy" streets and then find yourself hopelessly stuck in a traffic jam.
Please discuss dynamic programming, greedy, and iterative improvement algorithm design technique with an example . Also,...
7. Explain Dynamic Program ming algorithm in contrast to Divide and Conquer algorithm Discuss the advantages of Dynamic Programming over the other iophs method. 5pts) Then find the LCS of the following two strings X ABCBDAB) and Y- (BDCABA) (Explain the algorit g two strings. (He pts) thm as well 8. a) Explain the difference between recursive and iterative algorithms.(2 pts) b) The recursive Euclid algorithm is given as below: int GCD(int a, int b) f (b0) return a else...
1) Which Design Technique was used to produce Kruskal's Algorithm? (Select the answer from the following options and prove your choice): a) Dynamic Programming b) Greedy c) Divide and Conquer d) Linear Programming PLEASE EXPLAIN IT IN DETAIL
A) Write the pseudocode for an algorithm using dynamic programming to solve the activity-selection problem based on this recurrence: c[i, j] = 0 if Si; = Ø max {c[i, k] + c[k,j] + 1} if Sij +0 ak eSij B) Analyze the running time (the time complexity) of your algorithm and compare it to the iterative greedy algorithm.
Design a dynamic programming algorithm for the problem. Define the original problem as a function that takes parameters, and return some results. Define the subproblems Write recursive formula that relates a problem's solution to solutions of smaller subproblems. Finally write out pseudocode for the algorithm (using top-down memoization or bottom-up) Suppose a list Р[L..n] gives the daily stock price of a certain company for a duration of n days, we want to find an optimal day di to buy the...
Give a dynamic programming algorithm that runs within the time
complexity. Also give the space complexity of the algorithm.
Please
Given a directed graph with non-negative integer edge weights, a pair of vertices s and t, and integers K and W, describe a dynamic-programming algorithm for deciding whether there exists a path from s to t that has total weight W and uses exactly K edges. Your algorithm should run in time O(nm)WK). Analyze the time- and space-complexity of your...
Biotech Workshop HW 2 1. Compare and contrast Southern blot and Western blot on basic technique such as procedure, reagents, its usage and applications. (5points) 2. Discuss common features of Random Probe Labeling share with RT-PCR. What are major differences between these two techniques? (5points) 3. It is claimed by a pharmaceutical company that protein A' is beneficial to treat breast cancer since it promotes apoptosis. If you were put into charge of testing this, how would you design experiment?...
only Q 1 please
is is the last homework. 1. Compare and contrast designing via gain versus designing via compensation (what's the same? what's different? advantages? disadvantages? etc.). Also, discuss the effects of adding a zero or a pole. Solution: 2. What kind of compensation improves steady state error? List all and indicate whether they are active or passive. Solution: 3. Cascade compensation to improve transient response is based upon what pole-zero placement of the compensator? Also, state the reasons...
Psuedocode works! DP is dynamic programming for this
algorithm
Problem 4.2. (Difficulty 3) Seam carving is a real-world application of DP for content- aware image resizing. The simplest way to reduce the size of an image is cropping and scaling, i.e. cutting out parts of the image and scaling down the size. However, cropping leaves visible crop lines of incontinuity while scaling reduces the details of the image. We would like to intelligently reducing the size while accounting for the...
Programming language: Java
Home Work No.2 due 09.11.2019 either ascending or descending SORTING: An array is said to be ordered if its values order. In an ascending ordered array, the value of each element is less than or equal to the value of the next element. That is, [each element] <= [next element]. A sort is an algorithm for ordering an array. Of the many different techniques for sorting an array we discuss the bubble sort It requires the swapping...
Python 2.7.14 Programming Assignment Shape Drawing With
Notepad++(PLEASE READ AND FOLLOW THESE INSTRUCTIONS THOROUGLY AS
THIS ASSIGNMENT IS FOR PYTHON 2.7.14. ONLY AND I REALLY NEED THIS
TO WORK!!! ALSO PLEASE HAVE THE CODE PROPERLY INDENTED, WITH
WHATEVER VARIABLES DEFINED, WHATEVER IT TAKES TO WORK FOR PYTHON
2.7.14. I feel like nothing I do is working and I'm trying
everything I can think of. ):
In this assignment, the student will create a Python script that
implements a series of...