lecture 10 - Amrita

Lecture 10 Amrita - Greedy Strategy Greedy Strategy There are n number of candidates and k number of seats The problem is to choose the most

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Greedy Strategy 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 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 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 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 Greedy Strategy : Let us Consider an Illustration n = 3 ( l 1 , l 2 , l 3 ) = (5, 10, 3)...
View Full Document

This document was uploaded on 04/22/2010.

Page1 / 96

Lecture 10 Amrita - Greedy Strategy Greedy Strategy There are n number of candidates and k number of seats The problem is to choose the most

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online