# Register now to access 7 million high quality study materials (What's Course Hero?) Course Hero is the premier provider of high quality online educational resources. With millions of study documents, online tutors, digital flashcards and free courseware, Course Hero is helping students learn more efficiently and effectively. Whether you're interested in exploring new subjects or mastering key topics for your next exam, Course Hero has the tools you need to achieve your goals.

3 Pages

### lec12

Course: CSCI 6212, Fall 2010
School: GWU
Rating:

Word Count: 534

#### Document Preview

6212 Lecture { } CSCI 12 Design and Analysis of Algorithms Hoeteck Wee hoeteck@gwu.edu . Second representative problem weighted interval scheduling. Input: set of jobs with start times, nish times and weights. Find max weight subset of non-overlapping jobs greedy works with earliest nish time rst if all weights are equal (here, returns [12, 13, 16], not optimal) 1. use dynamic programming to nd opt...

Register Now

#### Unformatted Document Excerpt

Coursehero >> District of Columbia >> GWU >> CSCI 6212

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.
6212 Lecture { } CSCI 12 Design and Analysis of Algorithms Hoeteck Wee hoeteck@gwu.edu . Second representative problem weighted interval scheduling. Input: set of jobs with start times, nish times and weights. Find max weight subset of non-overlapping jobs greedy works with earliest nish time rst if all weights are equal (here, returns [12, 13, 16], not optimal) 1. use dynamic programming to nd opt := weight of max weight subset 2. use back-tracking to compute a subset with weight opt . Second representative problem weighted interval scheduling. Input: set of jobs with start times, nish times and weights. Find max weight subset of non-overlapping jobs 1. use dynamic programming to nd opt := weight of max weight subset need to break down opt into sub-problems opt[i] := weight of max weight subset amongst jobs 1, 2, . . . , i (sort jobs in order of increasing nish time) answer corresponds to opt[n] . Weighted interval scheduling 1st goal. nd opt := weight of max-weight subset opt[i] := weight of max weight subset amongst jobs 1, 2, . . . , i opt(1) = 12 opt(2) = 20 opt(3) = 23 opt(4) = 25 = 12 + 13 opt(5) = 26 nd opt(6) recursively (using opt(1), . . . , opt(5)) choice : include vs exclude job 6 (weight 20) choice #1 : exclude job 6 best is opt(5) = 26 choice #2: include job 6 overlaps with jobs 3, 4, 5 best is 20 + opt(2) = 40 . Weighted interval scheduling 1st goal. nd opt := weight of max-weight subset opt[i] := weight of max weight subset amongst jobs 1, 2, . . . , i nd opt[i] recursively (using opt[1],...,opt[i-1]) choice : include vs exclude job i choice #1 : exclude job i best is opt[i-1] choice #2 : include job i nd largest s.t. j f[j] <= s[i] and set p[i] = j best is w[i] + opt[j] opt[i] = max(opt[i-1], w[i] + opt[j]) . Weighted interval scheduling 1st goal. nd opt := weight of max-weight subset opt[i] := weight of max weight subset amongst jobs 1, 2, . . . , i opt[i] = max(opt[i-1], w[i] + opt[p[i]]) algorithm. dynamic programming sort jobs by finish time opt = [0] * (n+1) p = [0] * (n+1) for i in range(1,n+1): find largest j s.t. f[j] <= s[i] ## using binary search p[i] = j opt[i] = max(opt[i-1], w[i] + opt[p[i]]) return opt[n] running time. O(n log n) 2nd goal. nd subset whose weight is opt remember each choice : include vs exclude job i exclude job i : return the subset corresponding to opt[i-1] include job i : return job i plus the subset corresponding to opt[p[i]] . Weighted interval scheduling step 1. solving the sub-problems (to nd opt := weight of max-weight subset) sort jobs by finish time compute p[1], p[2], ..., p[n] opt, include = [0] * (n+1), [False] * (n+1) for i in range(1,n+1): opt[i] = max(opt[i-1], w[i] + opt[p[i]]) include[i] = (w[i]+opt[p[i]] > opt[i-1]) step 2. back-tracking (to nd subset whose weight is opt) ans, i = [], n while i > 0: if include[i]: ans.append(i) i = p[i] else: i = i-1 return ans . General framework for dynamic programming computing opt vs solution opt := weight of max-weight subset solution is subset whose weight is opt use dynamic programming to nd opt break opt down into sub-problems opt corresponds to answer to some sub-problem solve sub-problems bottom-up recursively (gure out the choices) back-tracking to nd a solution keep track of parent pointers (and best choices) for each sub-problem . the end .
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:

GWU - CSCI - 6212
cfw_CSCI 6212Lecture 13Design and Analysis of AlgorithmsHoeteck Wee hoeteck@gwu.edu.AnnouncementsScheduleOct 26: Shortest paths | Midterm 2 reviewNov 2: Midterm 2 | Homework 3 outNov 9, 16: Network owsToday: More dynamic programmingNov 30: Mi
GWU - CSCI - 6212
cfw_CSCI 6212Lecture 14Design and Analysis of AlgorithmsHoeteck Wee hoeteck@gwu.edu.Longest common subsequence (LCS)problem. given two strings x, y, nd the longest common subsequence.CATACTHIEROGLYPHOLOGYMICHAELANGELObrute force: try all subs
GWU - CSCI - 6212
cfw_CSCI 6212Lecture 15Design and Analysis of AlgorithmsHoeteck Wee hoeteck@gwu.edu.AnnouncementsMidterm 2 on Nov 2 (Wed)one double-sided cheat sheettopics: greedy (no MST, no clustering), divide-and-conquer, dynamic programming (upto lecture 1
GWU - CSCI - 6212
cfw_CSCI 6212Lecture 16Design and Analysis of AlgorithmsHoeteck Wee hoeteck@gwu.edu.AnnouncementsHomework 3 and 4 are upMidterm 2 : mean 28, median 30, standard deviation 6Midterm 3 on Nov 30Topics: greedy, dynamic programming and network ows.
GWU - CSCI - 6212
cfw_CSCI 6212Lecture 17Design and Analysis of AlgorithmsHoeteck Wee hoeteck@gwu.edu.Reductionscommon theme.transform abstract problem into a graph problemrun a graph algorithm we know.Reductionscommon theme.transform abstract problem into a
GWU - CSCI - 6212
cfw_CSCI 6212Lecture 18Design and Analysis of AlgorithmsHoeteck Wee hoeteck@gwu.edu.Polynomial Time Algorithmsmany tasks can be solved in polynomial time (i.e. O(nc ), where c is a constant)sorting a list of n numbers: O(n log n)minimum spanning
GWU - CSCI - 6212
cfw_CSCI 6212Lecture 19Design and Analysis of AlgorithmsHoeteck Wee hoeteck@gwu.edu.Minimum cutDenitions1. Cut: set of edges whose removal render the graph disconnected2. Minimum cut: cut of the smallest size (size = # edges in the cut)14bd
Syracuse - PSY - 205
PSY205 Personality Ch. 12 What is Personality? - Consistency - Distinctiveness - Personality refers to an individual's unique constellation of consistent behavior traits. Personality Traits - A personality trait is a durable disposition to behave in a par
Syracuse - PSY - 205
PSY205 9/6/11 Biopsychology -Memory, thinking, mental illness Pineal Gland - Where soul exerts it will on the mind Definition: Bios, psyche, logos Rene Descartes (1569-1650) - 5ft 2 - Mathematician, soldier, philosopher - I think therefore I am - People h
Syracuse - PSY - 205
PSY205 9/8/11 John B. Watson - Behaviorism: Any overt o Genetics vs. Environment? Environment - Stimulus Response Psychology vs. Common sense - Is psychology common sense? NO - Common sense is . o Made up after the fact
Syracuse - PSY - 205
PSY205 9/15/11 Carolinne Koller's Presentation Sensations &amp; Preceptions Rene Descartes - La Haye, Touraine, France - Canon &amp; Civil Law - Philo, Psych - Mind, body, soul - Contributed to psychology o Flow of &quot;animal spirit&quot; o Books Meditations on first phi
Syracuse - HST - 112
HST 112Worksheet: Communism, Fascism, National SocialismSovietCommunismItalianFascismIdeologicalUtopian, antifeatures and/or liberal,ideological core socialismClassesNature/style of Communismrulestate controlslife, everyequalNature ofSuppr
Syracuse - PSY - 223
CHAPTER 15 DRUG ADDICTION PSY 223 SPRING 2012HOW ARE DRUGS ADMINISTERED? ORAL INGESTION INJECTION INHALATION ABSORPTION THROUGH MUCOUS MEMBRANESTYPICAL MAINLININGFASTEST WAY TO GET DRUG INTO BRAIN NO CHANCE TO CHANGE BEHAVIORTHE DOSE-RESPONSE CURVE D
Syracuse - PSY - 223
PSY223 Notes 4/23/12 CH.15 Drug Addiction How Are Drugs Administered - ORAL INGESTION - INJECTION - INHALATION - ABSORPTION THROUGH - MUCOUS MEMBRANES Typical Mainlining - Fastest way to get drug into brain - No chance to change behavior Often the more yo
Syracuse - PSY - 335
PSY335Discipline Styles- Power assertiono Physical force or threat of physical force to control behavioro Taking away privileges or possessionso Used by 90% of parentsPower Assertion- Spankingo Boys spanked more often than girlso Mothers do more
Syracuse - PSY - 335
PSY335Early ChildhoodSocial and Emotional DevelopmentSelf Concept- Schema/mental representation of self- All our knowledge about who we are- Beliefs about our attributes &amp; capabilitiesSelf Concept Contents- Internalo Psychological Traitso Feelin
Syracuse - PSY - 335
PSY335Early Childhood:Cognitive Development3/28/12Conservation- After asking children to judge the quantity, length, or number.- When make incorrect judgments, children say:Conservation Errors- Reasoning errors involve Contractiono Thinking about
Syracuse - EAR - 111
EAR111 Recitation Quiz Week of 10/24 1. CO2 dissolves more readily into _. a. Warm water b. Cold water Correct answer: B 2. Which of the following is NOT a reason for ocean circulation? a. Winds b. Salinity of the water c. Temperature of the water d. Oxyg
Syracuse - PSC - 121
PSC121 Quiz 11. Match each of these with the statement below that defines the conceptC LibertyF IndividualismA EqualityE The social contractB ConstitutionalismD CapitalismA. The notion that all individuals are equal in their moral worth and thereb
Syracuse - PSC - 121
PSC121EXAM 1T or F 1. A conservative ideologue is someone who thinks that opportunity in America isno available to enough people and we should expand access to opportunity through moregovernment programsCorrect Answer: FT or F 2. A liberal thinks th
Syracuse - PSC - 121
Nicolas4/6/11Discussion Teacher: JennPSC121MEMOFor next weeks recitation you must write a one-two page memo (per the syllabusrequirements). This memo must be supported with evidence you find in the books especially Bianco and Canon. If there are sp
Syracuse - PSC - 121
PSC 121 Quiz 6ElectionsT F 1. A closed primary is one in which only those registering as a party member can voteCorrect Answer TT F 2. In presidential primaries, Republicans use winner-take-all rules for deciding whowins a states delegates while Demo
Syracuse - PSC - 121
PSC121 Quiz 7Congress1. In 2008 House districts that voted at lower levels for Obama elected:a. Equal percentages of Democrats and Republicansb. More Republicans than Democratsc. More Democrats than RepublicansCorrect Answer: BT F 2. The stimulus b
Syracuse - PSC - 121
PSC121 Quiz 8Congress1. Paul Ryans video says that over the next several decades the debt of the federalgovernment as a percentage of national income will:a Increaseb. Stay about the samec. DecreaseCorrect Answer: A2. The graphic video of tax obli
Syracuse - PSC - 121
PSC121: Quiz 3Civil Liberties and Public Opinion1. The essential reason for our civil liberties is to:a. Restrain citizen so they will operate in a reasonable way within a democracyb. Protect citizens from a government that may intimidate themc. Bala
Miami University - COM - 437*
Bolstering: The new theater productions will include interactive plays, musicals, anddance performances for children to enjoy while parents are gambling, in order to create a family atmosphere. The first underlined sentence is bolstering because we are r
Miami University - COM - 437*
April 23, 2012 Contact Information: John Smith, Communication Director FOR IMMEDIATE RELEASE Office: (609) 451-6102 Fax: (609) 851-5472 Email: john.smith@mamas.com MAMA'S CASINO ADDRESSES RECENT COMMISSION VIOLATIONS ATLANTIC CITY, NJ-The New Jersey Gamin
Miami University - SOC - 265
Professor LuMing Mao April 23, 2012Beyond Bias, Binary, and Border: Enacting a Discursive Third in Comparison RhetoricsProfessor LuMing Mao's lecture consisted of concepts I have never heard of before. He spoke about the &quot;discursive third&quot;, &quot;dao&quot;, &quot;zira
Harvard - STATS - 107
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39FMAGX -0.105296 -0.075943 0.139102 0.136679 0.060516 -0.013755 0.087637 0.02166 0.053087 -0.054276 0.054496 0.03876 -0.043688 0.030076 0.066288 0.0
Harvard - STATS - 107
Stat 107 Spring 2012 HW #5 Solutions1 (a) The following weights are obtained from Excel Solver (note: since we are dealing with minimizing an absolute value, there is NOT ONE UNIQUE SOLUTION, and the weights you get may vary slightly): Description FMAGS
Harvard - STATS - 107
### Prob #2 function##pairs.trade=function(ticker1, ticker2, from=&quot;2007-01-01&quot;, to=Sys.Date(),type=&quot;z.diff&quot;,threshold=2,closeout=T)cfw_ require(quantmod) names=c(ticker1,ticker2) y=getSymbols(ticker1,auto.assign=F,from=from,to=to) x=getSymbols
Harvard - STATS - 107
Stat 107 - Spring 2012 - HW4 SolutionsQuestion 1a)Table 1: Beta from Different Sources Google JNJ 0.53 IBM 0.65 MSFT 1.00 GOOG 1.08 GE 1.58 DIS 1.21 UPS 0.83 MU 1.25 BA 1.22 C 2.56 AAPL 1.25 Yahoo Reuters MM (SPY) 0.45 0.53 0.45 0.60 0.66 0.59 1.05 1.0
Harvard - STATS - 107
Stat 107 Spring 2012 Homework #3 Solutions1. The Portfolio which invests 35.28% in stock A and the rest in stock B gives a higher mean return (42.62%) for the same standard deviation. This is shown below: stock A stock B Portfolio mean 14.25% 62.72% 45.6
Harvard - STATS - 107
Stat 107 Spring 2012Harvard UniversityHomework 2 Solutions 1. GMC Envoys See hw2 q1.R for code. Our goal is to find the order size S that gives us the highest average profit across simulations of D. Given consumer demand D and an order size S, the deale
Harvard - STATS - 107
Interest Initial Deposit Year 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Value8% \$155\$167.40 \$180.79 \$195.26 \$210.88 \$227.75 \$245.97 \$265.64 \$286.89 \$309.85 \$334.63 \$361.40 \$390.32 \$421.54 \$455.27 \$491.69 \$531.02 \$573.50 \$619.38 \$668.93 \$722.4
Harvard - STATS - 107
Stat 107 Spring 2012 Homework 1 Solutions1) 2) 3) 4) 5) See Excel file &quot;Problem 1&quot; See Excel files &quot;Problem 2.1&quot; and &quot;Problem 2.2&quot; See Excel file &quot;Problem 3&quot; See Excel file &quot;Problem 4, 5&quot; See Excel file &quot;Problem 4, 5&quot;6) Note: in this problem, we used th
Harvard - STATS - 107
Harvard - STATS - 107
Harvard - STATS - 107
#1) Style Analysislibrary(quantmod)getSymbols(&quot;VWNDX&quot;,from=&quot;2009-01-01&quot;,to=&quot;2012-03-31&quot;)getSymbols(&quot;VDIGX&quot;,from=&quot;2009-01-01&quot;,to=&quot;2012-03-31&quot;)getSymbols(&quot;VHGEX&quot;,from=&quot;2009-01-01&quot;,to=&quot;2012-03-31&quot;)getSymbols(&quot;VITAX&quot;,from=&quot;2009-01-01&quot;,to=&quot;2012-03-31&quot;)VW
Harvard - STATS - 107
#Pairs Trading Companies:#Home Depot (&quot;HD&quot;) and Lowes (&quot;LOW&quot;)#Papa Johns (&quot;PZZA&quot;) and Dominoes (&quot;DPZ&quot;)#Walmart (&quot;WMT&quot;) and Target (&quot;TRGT&quot;)#McDonalds (&quot;MCD&quot;) and Taco Bell/KFC/Pizza Hut (&quot;YUM&quot;)#Dell (&quot;DELL&quot;) and HP (&quot;HPQ&quot;)#Coke (&quot;COKE&quot;) and Pepsi (&quot;
Harvard - STATS - 107
#1)library(quantmod)f=file.choose() #choosing a file that has the ticker namesthis one has 500 of them!crap=read.csv(f)tickers=as.character(crap[,1])getSymbols(&quot;SPY&quot;, from = &quot;2009-03-01&quot;, to = &quot;2012-02-29&quot;,auto.assign = T)SPY.monthret=monthlyReturn(
Harvard - STATS - 107
#1)#Monthly Returns over last 10+ yearslibrary(quantmod)getSymbols(tickers, from = &quot;2002-01-01&quot;, to = &quot;2012-02-01&quot;) stocks=list(IBM,MCD,KFT,F)means=100*apply(cbind(monthlyReturn(IBM),monthlyReturn(MCD),monthlyReturn(KFT),monthlyReturn(F),2,mean)sds
Harvard - STATS - 107
### Section 1 Code:# Playing with R and quantmod###R can do math:(10.5-12)/(5/sqrt(30)exp(2)sin(pi/6)#R has some built-in functions, that you can pass options (aka, parameters in a comp. sci. sense) to:log(10)log(10, base = 10)#You can store
Harvard - STATS - 107
Stat 107Section #10April 18 &amp; 19, 2012Logistics Kevin Rader, krader@hsph.harvard.edu. Sections: Wed 1-2pm (SC-B10), Thurs 12-1pm (SC-216).Office Hours (SC-602): Wed 2-3pm, Thurs 2-3pm, Fri 1-3pm, Mon 2-3pm, Tues 2-3pm Required Lecture on Thursday (W
Harvard - STATS - 107
Stat 107Section #9April 11 &amp; 12, 2012Logistics Kevin Rader, krader@hsph.harvard.edu. Sections: Wed 1-2pm (SC-B10), Thurs 12-1pm (SC-216).Office Hours (SC-602): Wed 2-3pm, Thurs 1-2pm, Fri 2-3pm Project Proposal: is due Thurs evening by 11:59pm. Plea
Harvard - STATS - 107
Stat 107Section #8April 4 &amp; 5, 2012Logistics Kevin Rader, krader@hsph.harvard.edu. Sections: Wed 1-2pm (SC-B10), Thurs 12-1pm (SC-216).Office Hours (SC-602): Wed 2-3pm, Thurs 1-2pm, Fri 2-3pm, Tues (April 10): TBD Homework #5 is due Tuesday night by
Harvard - STATS - 107
Stat 107Section #7March 28 &amp; 29, 2012Logistics Kevin Rader, krader@hsph.harvard.edu. Sections: Wed 1-2pm (SC-B10), Thurs 12-1pm (SC-216).Office Hours (SC-602): Wed 2-3pm, Thurs 1-2pm, Fri 2-3pm Homework #5 is due Tuesday, April 10, before midnight.
Harvard - STATS - 107
Stat 107Section #6March 21 &amp; 22, 2012Logistics Kevin Rader, krader@hsph.harvard.edu. Sections: Wed 1-2pm (SC-B10), Thurs 12-1pm (SC-216).Office Hours (SC-602): Wed 2-3pm, Wed 3-5pm (this week only), Thurs 1-2pm, Fri 2-3pm Homework #4 is due Tuesday
Harvard - STATS - 107
Stat 107Section #5February 29 &amp; March 1, 2012Logistics Kevin Rader, krader@hsph.harvard.edu. Sections: Wed 1-2pm (SC-B10), Thurs 12-1pm (SC-216).Office Hours (SC-602): Wed 2-3pm, Thurs 1-2pm, Fri 2-3pm Homework #3 is due Friday night before midnight
Harvard - STATS - 107
Stat 107Section #4February 22 &amp; 23, 2012Logistics Kevin Rader, krader@hsph.harvard.edu. Sections: Wed 1-2pm (SC-B10), Thurs 12-1pm (SC-216).Office Hours (SC-602): Wed 2-3pm, Thurs 1-2pm, Fri 2-3pm Homework #3 is due next Friday night, Mar 2, before
Harvard - STATS - 107
Stat 107Section #3February 15 &amp; 16, 2012Logistics Kevin Rader, krader@hsph.harvard.edu. Sections: Wed 1-2pm (SC-B10), Thurs 12-1pm (SC-216).Office Hours (SC-602): Wed 2-2:30pm, Thurs 1-1:30, Fri 2-3pm Homework #2 is due on Friday night, Feb 17th, be
Harvard - STATS - 107
Stat 107Section #2February 7-9, 2012Logistics Kevin Rader, krader@hsph.harvard.edu. Sections: Wed 1-2pm (SC-B10), Thurs 12-1pm (SC-216).Office Hours (SC-602): Wed 2-3pm, Fri 2-3pm Course website: my.harvard.edu/k85336. All section material will be
Harvard - STATS - 107
Stat 107Section #1February 1 &amp; 2, 2012Logistics Kevin Rader, krader@hsph.harvard.edu. Office hours (SC-602): Wed 2-3pm, Fri 1-2pm (TBD in future) Course website: my.harvard.edu/k85336. All section material will be posted under 'Sections Kevin's Sect
Harvard - STATS - 107
Stat 107: Introduction to Business and Financial StatisticsClass 25: Behavioral Finance and Wrap Up1Cognitive BiasesFundamental Limitations InHuman Mental ProcessesSimple Rules Of Thumb LeadingTo Faulty JudgmentsSimilar To Optical IllusionsPhysic
Harvard - STATS - 107
Stat 107: Introduction to Business and Financial StatisticsClass 23: Technical Analysis1IntroductionTechnical analysis is the attempt to forecaststock prices on the basis of market-deriveddata.Technicians (also known as quantitativeanalysts or cha
Harvard - STATS - 107
Stat 107: Introduction to Business and Financial StatisticsClass 22: A brief time on time series analysis1Time-Series Data and DependenceTime-series data are simply a collection ofobservations gathered over time.All the finance data weve looked at h
Harvard - STATS - 107
Stat 107: Introduction to Business and Financial StatisticsClass 21: VaR and Resampling1Value at RiskSimply put, assume you have a \$1,000,000portfolio (very cool! )You ask: What is the probability that I'd lose\$X (OR MORE) over the next M months?M
Harvard - STATS - 107
Stat 107: Introduction to Business and Financial StatisticsClass 19: Value at Risk1Playing with PerformanceAnalyticsSome R CodegetSymbols(&quot;AAPL&quot;,from=&quot;2009-01-01&quot;)getSymbols(&quot;JNJ&quot;,from=&quot;2009-01-01&quot;)getSymbols(&quot;SPY&quot;,from=&quot;2009-01-01&quot;)aaplret=monthl
Harvard - STATS - 107
Stat 107: Introduction to Business and Financial StatisticsClass 18: Performance Analytics, part 21Style AnalyticsIs a forthcoming package in R that will allowone to do style analysis; in particular rollingstyle analysis.Recall, we assume the style
Harvard - STATS - 107
Stat 107: Introduction to Business and Financial StatisticsClass 17: Performance Analytics, part 112Pairs Trading ReduxWe have you backtest a pairs tradingstrategy on this weeks homework.Based on an idea presented in a Brazilianpaperpaper on the
Harvard - STATS - 107
Stat 107: Introduction to Business and Financial StatisticsClass 16: Pontificating about the Project and Beta1The Class ProjectImportant DatesApril 10th: project proposalMay 1st: project dueThere are least two directions one can takefor the final