{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture 10 - Amrita

# lecture 10 - Amrita - Greedy Strategy Greedy Strategy There...

This preview shows pages 1–11. Sign up to view the full content.

Greedy Strategy

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Greedy Strategy : There are n number of candidates, and k number of seats. The problem is to choose the most appropriate k candidates from n candidates A = a n .. .. .. .. a 3 a 2 a 1 S = s k .. .. .. .. s 3 s 2 s 1 Since k n S A The approach to fill up ‘S’ is to maximize the objective called MOST APPROPRIATE An ambitious search through A will result in S. Greed to Maximize the Profit GREEDY STRATEGY
Most of these problems have n inputs and require us to obtain a subset that satisfies some constraints Greedy Strategy : Any Subset that satisfies the given constraints is called a feasible solution We are required to find a feasible solution that either maximizes or minimizes a given objective function A feasible solution that does this is called an OPTIMAL SOLUTION

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
For Greedy Strategy : We can suggest a two stage algorithm : 1. Arrange the input in the best possible sequence i.e the most appropriate elements would be available starting from the beginning of the list with the most deserving / the most meritorious element appearing as the first element 2. Test element by element whether to include the current element into the SOLUTION set or not. Preprocessing Solving Greedy Sequencing Creating the solution set
For Greedy Strategy : Once the data is given in the greedy sequence then the solution is obtained using - O algorithm t lb first k searches successfully declaring the elements as relevant t lb k (k) t ub Scan goes up to the end of the data list t ub n O(n) However what is really most important is PREPROCESSING – GREEDY SEQUENCING

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
For Greedy Strategy : Control abstract of greedy strategy based algorithm is given below : Procedure greedy (A, n) { Solution φ for i 1 to n { x Select(A) If feasible(solution , x) then solution U(Solution,x) } }
1. Optimal Storage on Tapes Tape is a sequential storage medium l d l c l b l a Let us assume that the pointer always gets reset to START position Let us consider n files of lengths l 1 , l 2 , . . . , l n to be stored on the tape of length L L l 1 + l 2 + . . . +l n Time to retrieve any file is proportional to the length of the tape to be traversed starting from the beginning

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Question : In what sequence should the files be stored such that the MRT (mean retrieval time) is minimized If l 1 , l 2 , l 3 , l 4 are the lengths of 4 files stored in that sequence Time to retrieve file-1 = t 1 l 1 Time to retrieve file-2 = t 2 (l 1 + l 2 ) Time to retrieve file-3 = t 3 (l 1 + l 2 + l 3 ) Time to retrieve file-4 = t 4 (l 1 + l 2 + l 3 + l 4 ) Time to retrieve i th file = t i l k k = 1,i
Greedy Strategy : What should be the sequence of files of different lengths such that MRT is minimized Total retrieval Time = T l k i = 1,n k = 1,i Mean retrieval Time = T mean (1/n) l k i = 1,n k = 1,i

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Greedy Strategy : Let us Consider an Illustration n = 3 ( l 1 , l 2 , l 3 ) = (5, 10, 3) Exhaustive trials : n! = 3! = 6 possible ways of loading Sequence T MRT 1,2,3 5 + ( 5 + 10) + (5+10+3) 38/3 1,3,2 5 + ( 5 + 3) + ( 5 + 3 + 10) 31/3 2,3,1 10 + ( 10 + 3) + ( 10 + 3 + 5) 41/3 2,1,3 10 + ( 10 + 5) + ( 10 + 5 + 3) 43/3 3,1,2 3 + ( 3 + 5) + ( 3 + 5 + 10) 29/3 3,2,1 3 + ( 3 + 10) + ( 3 + 10 + 5) 34/3 Therefore, Most Optimal Ordering 3, 1, 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}