2 Pages

Greedy

Course: CS 263, Fall 2009
School: CSU Channel Islands
Rating:
 
 
 
 
 

Word Count: 758

Document Preview

and Outline Reading The Greedy Method The Greedy Method Technique (5.1) Fractional Knapsack Problem (5.1.1) Task Scheduling (5.1.2) Minimum Spanning Trees (7.3) [future lecture] The Greedy Method 1 The Greedy Method 2 The Greedy Method Technique The greedy method is a general algorithm design paradigm, built on the following elements: configurations: different choices, collections, or values to find objective...

Register Now

Unformatted Document Excerpt

Coursehero >> California >> CSU Channel Islands >> CS 263

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
and Outline Reading The Greedy Method The Greedy Method Technique (5.1) Fractional Knapsack Problem (5.1.1) Task Scheduling (5.1.2) Minimum Spanning Trees (7.3) [future lecture] The Greedy Method 1 The Greedy Method 2 The Greedy Method Technique The greedy method is a general algorithm design paradigm, built on the following elements: configurations: different choices, collections, or values to find objective function: a score assigned to configurations, which we want to either maximize or minimize Making Change Problem: A dollar amount to reach and a collection of coin amounts to use to get there. Configuration: A dollar amount yet to return to a customer plus the coins already returned Objective function: Minimize number of coins returned. Greedy solution: Always return the largest coin you can Example 1: Coins are valued $.32, $.08, $.01 Has the greedy-choice property, since no amount over $.32 can be made with a minimum number of coins by omitting a $.32 coin (similarly for amounts over $.08, but under $.32). It works best when applied to problems with the greedy-choice property: a globally-optimal solution can always be found by a series of local improvements from a starting configuration. The Greedy Method 3 Example 2: Coins are valued $.30, $.20, $.05, $.01 Does not have greedy-choice property, since $.40 is best made with two $.20s, but the greedy solution will pick three coins (which ones?) The Greedy Method 4 The Fractional Knapsack Problem Given: A set S of n items, with each item i having Goal: Choose items with maximum total benefit but with weight at most W. If we are allowed to take fractional amounts, then this is the fractional knapsack problem. In this case, we let xi denote the amount we take of item i Objective: maximize bi - a positive benefit wi - a positive weight Example Given: A set S of n items, with each item i having Goal: Choose items with maximum total benefit but with weight at most W. knapsack Solution: Items: Weight: Benefit: Value: 5 1 2 3 4 5 bi - a positive benefit wi - a positive weight b (x / w ) iS i i i The Greedy Method 4 ml $12 3 8 ml $32 4 2 ml $40 20 6 ml $30 5 1 ml $50 50 10 ml Constraint: xi W iS 2 1 6 1 ml ml ml ml of of of of 5 3 4 2 ($ per ml) The Greedy Method 6 The Fractional Knapsack Algorithm Greedy choice: Keep taking item with highest value (benefit to weight ratio) Since bi ( xi / wi ) = (bi / wi ) xi iS iS Run time: O(n log n). Why? Algorithm fractionalKnapsack(S, W) Input: set S of items w/ benefit bi and weight wi; max. weight W Output: amount xi of each item i to maximize benefit w/ weight at most W for each item i in S xi 0 {value} vi bi / wi {total weight} w0 while w < W remove item i w/ highest vi xi min{wi , W - w} w w + min{wi , W - w} 7 Task Scheduling Given: a set T of n tasks, each having: Goal: Perform all the tasks using a minimum number of machines. Machine 3 Machine 2 Machine 1 A start time, si A finish time, fi (where si < fi) Correctness: Suppose there is a better solution there is an item i with higher value than a chosen item j, but xi<wi, xj>0 and vi<vj If we substitute some i with j, we get a better solution How much of i: min{wi-xi, xj} Thus, there is no better solution than the greedy one 1 2 3 4 5 6 7 8 9 The Greedy Method The Greedy Method 8 Task Scheduling Algorithm Greedy choice: consider tasks by their start time and use as few machines as possible with Algorithm taskSchedule(T) this order. Input: s...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

CSU Channel Islands - ICS - 225
Statistics 225Contact:Bayesian Statistical AnalysisProfessor Hal Stern Department of Statistics 346D Computer Science ZOT 1250 ph: 824-1568 email: sternh@uci.edu course web: www.ics.uci.edu/~sternh/courses/225/When: MWF 11am-11:50am Where: Soc
UCSD - EC - 120
ECON 120A, SPRING 2003 - ANSWERS TO HOMEWORK #1 1. Wealthy landlord = B C . Republican non-public employee = D E. Either of these groups is denoted by P = (B C) (D E). The statement is that A is a subset of this. Thus, we have A (B C) (D E).
Ohio State - EE - 700
ECE-700 Multirate NotesPhil Schniter March 27, 20061Fundamentals of Multirate Signal Processing Upsampling: The operation of upsampling by factor L N describes the insertion of L1 zeros between every sample of the input signal. This is denoted
Princeton - COS - 495
The Art, Science, History and Future of Clinical Decision Support SystemsRandolph A. Miller, MD '71 P `03 Professor &amp; Chair, Department of Biomedical Informatics, Professor of Medicine, and Associate Director, Informatics Center Vanderbilt Universi
Princeton - COS - 598
| { } xz v w z v | { x t { w u t ~ v w t z t w t x ~ u y { } v x t w { t w { | t x ~ x x z t x w { u u ~ v x } w v v xv y v v y ~ u t t } v v w } v z x } t x ~ x x z
UCF - MAP - 2302
MAP 2302Quiz #2Name:1. [2.1] Determine a region of the xy-plane for which the dierential equation x dy =y dxwould have a unique solution through any point (x0 , y0 ) in the region. Justify your answer.2. [2.2] Solve the dierential equation x
UCF - MAC - 1930
MAC 1930H Midterm 1 A 136 121 120 118 116 114, 114 113 107 104 77 56(Spring 2009)A-B+ B C D(Mean = 108)
UCSD - MATH - 181
Math 181A. Handout #12 A Motivation for Maximum Likelihood EstimationSetup: Assume that X has a binomial distributionn f X (x ; n, ) = x (1 )n x ; x = 0, 1, 2, . , n x In particular, suppose we observe n = 10 (coin tosses) and the probabi
CSU Channel Islands - ICS - 280
The Security ProblemSecurityThe Security Problem Authentication Program Threats System Threats Threat Monitoring Encryption Security must consider external environment of the system, and protect it from: unauthorized access. malicious modifica
UCLA - BIOSTAT - 411
403 403101 1 0 2 3 403 403101 1 0 4 4 403 403101 1 0 4 3 403 403101 1 0 3 4 403 403101 1 0 3
Princeton - PHYS - 109
PRINTED NAME: Problem 1 2 3 Total Score /20 /20 /20 /60PHYSICS 109 MIDTERM EXAMINATIONOctober 24, 2001 7:309:00 pm McDonnell 105When you are told to begin, check that this examination booklet contains all the numbered pages from 2 through 7. The
Princeton - PHYS - 301
Homework 5 Solutions Problem 1 In our statistical mechanical analysis of the ideal gas (see the notes for lecture 7), we modelled the gas a system of point particles having three translational degrees of freedom. This is basically true for the monato
Princeton - PHYS - 301
Physics 30120-Oct-2002Physics 301 Problem Set 4 SolutionsProblem 1. There are 3N oscillators, each of frequency . The average energy of one oscillator is h/(exp( / ) - 1). The average energy of the system is the sum of the h average energies of
Purdue - ATT - 1000
Australasian Flow Cytometry Group Inc.ABN: 68 355 872 685 President: Ken Field Treasurer: Don Lear Secretary: Flavia Battistutta E-mail: flavia_battistutta@health.qld.gov.au Postal Address GPO Box 123 Royal Brisbane Hospital Queensland 4029 Australi
University of Illinois, Urbana Champaign - CS - 498
Firewall TechnologyCyber Security Spring 20072/1/2006CyberSecurity Spring 2007Outline Basics of firewalling Architectures Network Address Translation Logging Advanced Topics Identity in firewalls Multiple security levels Firewall Fut
University of Illinois, Urbana Champaign - CS - 225
University of Illinois, Urbana Champaign - CS - 421
1. Gives the types of the following Ocaml functions. type-correct.) (a) let a x y = x+y (b) let b (x,y) = x+y (c) let c (x,y) = x (d) let d x = match x with (a,b) -&gt; a (e) let e x = hd x + 1 (f) let f x y = match x with [] -&gt; 0 | a:b -&gt; a+y(All are
University of Illinois, Urbana Champaign - CS - 273
uring eln wthison turingP g PUQ r T rt I gollorted with hurhP nd skleene a fa; b; cgD a fa; b; c; x; y; tgD q1 is the strt stteD qa is the ept stteD nd the trnsitions to the rejet stte re impliit @see pge IRS of the textAF qive highElevel proedur
Purdue - AAE - 203
AAE 203, Spring 2004Test One Problem 1 Given that = 30 and V = 10 m, express the vector V shown in terms of the unit vectors e1 , e2 , and e3 . Problem 2 Consider the following two dierential equations (M l cos ) p + (M l2 ) M gl sin =
University of Illinois, Urbana Champaign - CS - 423
CS 423UG Fall 2005: Midterm Exam Solutions1 The RedGene Puzzle1. (a) (per-quantum) P1,P2,P3,P4,P5,P1,P3,P5,P1,P5,P1,P5,P1,P5,P1,P1,P1,P1,P1. (b) P2,P4,P3,P5,P1. (c) P2,P5,P1,P3,P4. 2. RR: (9+1+5+3+9)/5=5.4 tus. SJF:(9+0+2+1+4)/5=3.2 tus. Prio:(6+0
University of Illinois, Urbana Champaign - CS - 418
CS 318: Homework #3Assigned: November 18, 2003 Due: in class December 3, 2003Please be organized when writing your answers to these questions. Make sure that all solutions are clearly indicated and labelled with the question they are answering. Re
University of Illinois, Urbana Champaign - CS - 418
Visible Surface DeterminationThe Z-Buffer AlgorithmCreate new frame buffer channel a depth component to go with our RGB channels Records depth of pixel contents overwrite pixel thats farther away This used to look pretty wasteful say 24 bits *
University of Illinois, Urbana Champaign - CS - 533
IntroductionInstructor: Josep Torrellas CS533 Spring 2006Copyright Josep Torrellas 20031Introduction Why parallel architectures: Absolute performance Cost-performance Reliability and availability Key enabling factors: Advances in microp
University of Illinois, Urbana Champaign - CS - 440
Support Vector Machines &amp; Computer VisionIntroduction to Artificial Intelligence CS440/ECE448 Lecture 26 1-unit projects for grad students: Get in touch with me ! Next Tuesday: Review (everything since mid-term) Final: May 8, 1:30 to 3pm, hereLast
University of Illinois, Urbana Champaign - CS - 232
CS232 Midterm Exam 3 April 27, 2005Name: Section: This exam has 6 pages (nothing to tear off this time). You have 50 minutes, so budget your time carefully! No written references or calculators are allowed. To make sure you receive credit, ple
Princeton - PHYS - 301
Physics 301Homework No. 4Due 15-Oct-2002H4-11. Before Debyes theory of lattice vibrations, there was Einsteins theory. We will explore Einsteins theory in this problem. Assume that you have a solid consisting of N atoms. Assume each atom is a
Princeton - E - 144
Studies of nonlinear QED in collisions of 46.6 GeV electrons with intense laser pulsesC. Bamber, S.J. Boege,y T. Ko as, T. Kotseroglou,z A.C. Melissinos, D.D. Meyerhofer,x D.A. Reis and W. RaggDepartment of Physics and Astronomy, University of Roc
Princeton - E - 144
STRONG FIELD QEDKIRK T. MCDONALD Joseph Henry Laboratories, Princeton University, Princeton, NJ 08544A recent experiment performed in collaboration with Adrian Melissinos produced evidence for &quot;sparking the vacuum&quot;. This work is placed in the conte
Princeton - PH - 106
X Y 5~{q H mi qH sp F m x i t r t r Y r v d r xts g r t x r v rts s #u#wG3#GyWGwywq&quot;`0#wvG#yGG|q #8p Y x q#`Wd t x t r d Ww'GGt t v v t v t t r r x t x d d uW#wfl tswqAyGlWW#q~W~GfBG&quot;`&quot;#
Princeton - E - 144
PHYSICAL REVIEW D, VOLUME 60, 092004Studies of nonlinear QED in collisions of 46.6 GeV electrons with intense laser pulsesC. Bamber,* S. J. Boege, T. Koffas, T. Kotseroglou, A. C. Melissinos, D. D. Meyerhofer, D. A. Reis, and W. RaggDepartment of
Toledo - PHY - 2405
Superconducting RF CavitySuperconducting RF Cavity Installed in LEP
Toledo - PHY - 357
Toledo - PHY - 357
Princeton - AC - 339
Princeton - AC - 339
UCF - ISM - 3011
Department of Management Information Systems College of Business Administration University of Central FloridaSummer 2008 COURSE SYLLABUSEssentials of Management Information Systems ISM 3011SecCLASS INFORMATIONCOURSE TITLEPREFIX&amp; NUMBERDa
Princeton - PHI - 201
HOMEWORK #3 SOLUTIONS1. a)P Q Q P This is a substitution instance by replacing the variable P by Q and the variable Q by PPR This is not a substitution instance because substitution can only be performed on propositional variables, and not, fo
Princeton - PHI - 201
HOMEWORK #2 SOLUTIONS A. 1. 1 2 3 1,3 1,2,3 1,2 1 2. 1 2 1,2 1,2 1 3. 1 (1) 2 (2) 3 (3) 1,3 (4) 2,3 (5) 1,2,3 (6) 1,2 (7) 1 (8) (1) (2) (3) (4) (5) (1) (2) (3) (4) (5) (6) (7)PQ QR P Q R PR (Q R ) ( P R )A / ( Q R ) ( P R ) A A 1,3 MPP 2,4 M
Princeton - COS - 433
Lecture 8 - Message Authentication CodesBenny Applebaum , Boaz Barak October 12, 2007Data integrity Until now weve only been interested in protecting secrecy of data. However, in many cases what we care about is integrity. Maintaining integrity is
Princeton - COS - 433
Lecture 8 - Message Authentication Codes IIBoaz Barak October 12, 2005Order of Encryption and Authentication Recall the login problem: The login problem. Assume that client and server share a secret PIN P IN that was chosen at random between 0 and
UCF - MAE - 5318
How many ways can you put 5into or? Make a table to find out.Use this table to record your findings: In AllThere are _ ways. Describe patterns beginning to show in the table:Write your name initials:First name initial in the first colu
University of Illinois, Urbana Champaign - AE - 526
University of Illinois, Urbana Champaign - AE - 526
AE-526 Advanced Manufacturing of Composites Homework #2 (30 pts) DUE: 2/25/09 Carbon Fiber Processing 1. 2. 3. 4. 5. 6. 7. 8. Explain the difference between carbon and graphite fibers. What three main precursors are used to make carbon fibers? What a
University of Illinois, Urbana Champaign - PCHEMSEMIN - 0607
RESEARCH PAPERElectronic relaxation dynamics in DNA and RNA bases studied by time-resolved photoelectron spectroscopySusanne Ullrich,a Thomas Schultz,b Marek Z. Zgierskia and Albert Stolow*aawww.rsc.org/pccpPCCPbSteacie Institute for Mole
University of Illinois, Urbana Champaign - LIS - 451
Grad School of Lib &amp; Info Sci., Univ. of Illinoishttp:/www.lis.uiuc.edu/Operating Systems OverviewLIS 315 * Spring 2004 Introduction to Networked Systems http:/www.isrl.uiuc.edu/mwolske/lis315/spring04Martin Wolskemwolske@uiuc.edu1/32?i
University of Illinois, Urbana Champaign - LIS - 451
Grad School of Lib &amp; Info Sci., Univ. of Illinoishttp:/www.lis.uiuc.edu/Networks: The InternetLIS 315 * Spring 2004 Introduction to Networked Systems http:/www.isrl.uiuc.edu/mwolske/lis315/spring04Martin Wolskemwolske@uiuc.edu1/32?iPP
Princeton - PHYS - 312
Statistics and Error Analysis Phys 312 Experimental data always have noise. It is crucial to understand the origin and properties of noise and how to deal with it when interpreting your experimental results. In fact in some experiments (e.g. measurem
Princeton - PHYS - 551
Evaluation of the matrix elements for radiative transitions The transition matrix element for electic dipole transition is proportional to | e|E r|g |2 where |e and |g are described by some angular momentum quantum numbers. First consider the simple
Purdue - CS - 180
CS 180 Fall 2006 Exam IIThere are 20 multiple choice questions. Each one is worth 2 points. There are 3 programming questions worth a total of 60 points. Answer the multiple choice questions on the bubble sheet given and the programming questions on
Purdue - CS - 180
GUI and Event-Driven ProgrammingRecitation 3/6/2009CS 180 Department of Computer Science, Purdue UniversityAnnouncement Project 5 due Wed, Mar. 11 at 10 pm. All questions on the class newsgroup. Do not wait till the last minute to start yo
Purdue - CS - 180
University of Illinois, Urbana Champaign - MATH - 231
Merit Worksheet #34, 4/23/08Calculus and polar curves1. (a) Sketch the graph of y = 3 sin 2x. (b) Using information from your graph in part (a), sketch the graph of r = 3 sin 2. 2. (a) Sketch the graph of y = 1 + 2 cos x. (b) Using information from
University of Illinois, Urbana Champaign - MATH - 220
Math 220 (section B8) Fall 04 Malgorzata Konwerska Practice Questions for Exam #3 = Featuring 1.08: 1. Consider the predator - prey model prey[t] = a prey[t] - b prey[y] pred[t] pred[t] = -c pred[t] + d pred[t] prey[t] c where a, b, c, d are positive
Maryville MO - MCE - 565
Maryville MO - MCE - 366
MCE 366 System Dynamics, Spring 2009 Set 7Reading: Chapter 7, Sections 7.1, 7.3, and 7.4. Skip pages 391 and 392. Skip from page 398 (&quot;Use of Deviation Variables .&quot;) to page 399. Skip from page 410 (&quot;Pump Models&quot;) to page 418). Problems: 7.2, 7.6, 7
Maryville MO - MCE - 565
Maryville MO - EGR - 106
EGR 106 Lecture 8Loops, Break, Continue Commands &quot;for-end&quot;loops &quot;while-end&quot; loops Nested loops &quot;break&quot; and &quot;continue&quot; commands Textbook: 7.4 7.6LoopsCommands to repeatedly execute certain blocks of code Two common types in MATLAB: for
Maryville MO - ELE - 205
Order this document by AN1775/D Rev. 1Motorola Semiconductor Application NoteAN1775Expanding Digital Input with an A/D ConverterBy Brad Bierschenk Motorola Applications Engineering Austin, TexasIntroductionThis application note documents a
University of Illinois, Urbana Champaign - PHYS - 101
Physics 101 discussion week 4Relevant Lecture for Discussion SectionLecture 4-6: Forces and Motion along a Line (Chapter 3) and in Two Dimensions (Chapter 4). 1. Position and displacement 2. Velocity 3. Acceleration 4. Newtons second law 5. Motion
Maryville MO - ELE - 215
ELE 215 Spring 2009 Lab 3 Scope and SigGenObjectives Experiment with the signal generator and the oscilloscope Test KVL (voltage division) for time varying signals Observe and measure phase shift on the scope Notes See the sheet in the lab roo
Maryville MO - ELE - 215
ELE 215 Lab 3 Summary Report FormLab day (circle one): Mon Wed Tue Thur Names:1. SigGen and Scope Exercise (from the Beginners' Guide): Task Step 10 of &quot;Getting Started&quot; Just a square wave Step 5 of &quot;Measurements&quot; Showing a mean over 4 Step 18 of