# 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

### Handout 16

Course: CS 103B, Winter 2008
School: Stanford
Rating:

Word Count: 805

#### Document Preview

Sahami Mehran CS103B Handout #16 February 2, 2009 Problem Set #3 Due: 11:00am on Wednesday, February 11th Note: in the problems below in which you are asked for a big-Oh running time, we are looking for a tight big-Oh bound (analogous to the big-Theta () notation mentioned in class and in Handout #9), but you only need to show the upper bound (big-Oh). You do not need to show the lower bound. 1. In Handout #11,...

Register Now

#### Unformatted Document Excerpt

Coursehero >> California >> Stanford >> CS 103B

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.
Sahami Mehran CS103B Handout #16 February 2, 2009 Problem Set #3 Due: 11:00am on Wednesday, February 11th Note: in the problems below in which you are asked for a big-Oh running time, we are looking for a tight big-Oh bound (analogous to the big-Theta () notation mentioned in class and in Handout #9), but you only need to show the upper bound (big-Oh). You do not need to show the lower bound. 1. In Handout #11, we concluded that the recurrence relation for the running time of the recursive Binary search algorithm is (using constants x and y here): T(1) = x T(n) = T(n/2) + y Determine the big-Oh running time for this recurrence relations using: a. Repeated substitution. Use induction to prove that your closed form formula for T(n) is correct. b. Theorem 1 (Master Theorem) from Handout #10. Show how you got your result by explicitly stating the values of a, b, c, and d from the Theorem in terms of this recurrence, and how you computed the final big-Oh as a result. 2. Consider the number of permutations of a set with n elements. a. Find a recurrence relation for the number of permutations of a set with n elements. Make sure to explain how you came up with this recurrence. b. Use the recurrence you found in part (a) to find the number of permutations of a set with n elements using repeated substitution. (Note: you do not need to provide an inductive proof showing your formula is correct). 3. In this problem we consider a recurrence relation on bit strings (similar to the problem we did in class and Example 5 in Handout #10). a. Find a recurrence relation for the number of bit strings of length n that contain the substring 01. Make sure to explain how you came up with this recurrence. b. What are the initial conditions for the recurrence relation? c. How many bit strings of length 7 contain the substring 01? 2 4. Consider the recurrence relation: T(1) = a T(n) = 9T(n/3) + bn Determine the big-Oh running time for this recurrence relations using repeated substitution. Use induction to prove that your closed form formula for T(n) is correct. Note: this is one of the more involved problems on this problem set. You might want to check the correctness of your solution using the Master Theorem. 5. Consider the recurrence relation: T(1) = 1 T(n) = (1/2)T(n-1) + n Determine the big-Oh running time for this recurrence relations using repeated substitution. Use induction to prove that your form closed formula for T(n) is correct. Note: this is one of the more involved problems on this problem set. 6. Say that we came up with a new sorting algorithm that we name SuperQuickSort. SuperQuickSort works just like regular QuickSort, except that rather than picking a single pivot element and creating two sub-arrays, it picks (k 1) pivot elements ordered in increasing order, and generates k sub-arrays L1, L2, , Lk that contain the array elements with values between each respective pair of pivots. Hence, it makes k recursive calls to SuperQuickSort with each of these sub-arrays. Prove that SuperQuickSort still runs in time O(n log n) for any integer k >= 2, when each of the k sub-arrays have roughly equal numbers of elements in them. 7. In class, we discussed the Towers of Hanoi problem and explained that there is a deterministic O(2n) algorithm for solving this problem, where n is the number of disks. If we had a non-deterministic algorithm to solve this problem, would we be able to obtain a better running time? In other words, explain (informally) if Towers of Hanoi is really a problem in NP or in the Exponential complexity class. Make sure to explain the role of non-determinism in your answer. 8. A monomial is a conjunction of literals, where each literal is either some boolean variable or its negation. For example, (x1 & x2 & ~x3) is a monomial. Consider the problem of determining whether arbitrary disjunctions of two monomials are satisfiable (i.e., is there some assignment to the variables in the logical formula such that it is true). Explain informally whether this problem is in P or NP. In other words, is non-determinism required to solve such a restricted satisfiability problem in polynomial time? If the problem is in P, provide a polynomial time algorithm to solve the problem. If the problem is in NP, briefly explain why non-determinism is required to solve this problem in polynomial time. 3 9. Find the length of the longest common subsequence of the lists abacaabacab and bacababa using the dynamic programming algorithm discussed in class and in Handout #15. Make sure to also show the table that you generated in applying the algorithm. 10. Use the table you constructed in Problem #9 to find all paths for the longest common subsequences of the lists abacaabacab and bacababa. Explain the path (possibly multiple) taken through the table for each LCS.
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:

Stanford - CS - 103B
Mehran Sahami CS103BHandout #17 February 2, 2009Introduction to TreesHierarchical StructuresTrees are very useful conceptual tools for representing relationships among certain classes of items. For example, trees can be used to represent familial rela
Stanford - CS - 103B
Mehran Sahami CS103BHandout #19 February 6, 2009Practice Midterm ProblemsNote: the number of problems here is a larger than you will see on the actual midterm. More problems are provided here just to give you a bit more practice on a broader set of the
Stanford - CS - 103B
Mehran Sahami CS103BHandout #20 February 6, 2009Practice Midterm Problem Solutions(including some hints and shortcuts you might find useful for exams) 1. Order in which nodes are processed if we were to do a reverse preorder traversal on the tree: a, c
Stanford - CS - 106B
CS106B Winter 2009Handout 01CS106B Course InformationJerry Cainjerry@cs.stanford.eduJanuary 7th, 2009Instructor: E-Mail: Office phone: Office: Office hours: Lectures:725-8597 Gates 192 Wednesdays, 10:00 a.m. noon MWF 9:00 9:50 a.m. Gates Building,
Stanford - CS - 106B
CS106B Winter 2009Handout 02Early Programming: Landmarks and LandminesJanuary 7th, 2009Handout written by Julie Zelenski, Mehran Sahami, and Robert Plummer.After todays lecture, you should run home read all of Chapter 1 on your own. We won't teach th
Stanford - CS - 106B
CS106B Winter 2009Handout 03Two-Dimensional Grids and Queen SafetyJanuary 9, 2008This handout was written by Jerry.Today's larger example demonstrates the use of a grid of Boolean valuesthat is, a single declaration of a Grid&lt;bool&gt;to maintain informa
Stanford - CS - 106B
CS106B Winter 2009Handout 04C+ StringsJanuary 12, 2009Original handout written by Neal Kanodia, with help from Steve Jacobson.C+ Strings One of the most useful data types supplied in the C+ libraries is the string. A string is a variable that stores
Stanford - CS - 106B
CS106B Winter 2009Handout 05Crash Course: Records and FilesJanuary 12, 2009Your task is to design a data structure to keep track of the academic departments on campus. There are an unbounded numbers of departments, and each department has a name and a
Stanford - CS - 106B
CS106B Winter 2009Handout 06Assignment 1: Blocky!January 12, 2009Brand- new assignment!Your first assignment has you implement variation on a one-player game called Blocky. The rules are simple: click any single block and drag the mouse to outline a
Stanford - CS - 106B
CS106B Winter 2009Handout 07Good Programming StyleJanuary 14, 2009Thanks to Julie Zelenski, Nick Parlante, and Bob Plummer for this handout.As we will stress all quarter, a working program is only half the challengeconstructing an elegant and well-en
Stanford - CS - 106B
CS106B Winter 2009Handout 08DecompositionJanuary 14th, 2009Due to Nick Parlante.Decomposition is the process of breaking a large problem into more manageable subproblems. The motivating principle is that large problems are disproportionately harder t
Stanford - CS - 106B
CS106B Winter 2009Handout 09Coding StandardsJanuary 14th, 2009Handout written by Nick Parlante. Quite possibly the funniest handout ever.Landmarks in Coding Quality Let's honestly review the conceptual landmarks most programmers use when thinking abo
Stanford - CS - 106B
CS106B Winter 2009Handout 10C+ and CS106 Library ReferenceJanuary 14, 2009Written by Julie Zelenski.You're sitting at your computer, trying to write some code that manipulates a string or stream or draws some graphics. You know the functionality you
Stanford - CS - 106B
CS106B Winter 2009Handout 11Section Handout 1January 14, 2009Problem 1: Compiler, compiler, what do you want? You are working hard on your latest assignment and come up with the following code:enum directionT cfw_ North, East, South, West ; int main(
Stanford - CS - 106B
CS106B Winter 2009Handout 11SSection Solution 1January 14 - 16, 2009Problem 1: Compiler, compiler, what do you want? The line that will not compile in this example is the line that performs the assignment dir = num;. Why not? Enumerated types are repr
Stanford - CS - 106B
CS106B Winter 2009Handout 12MDebugging with XCodeJanuary 16, 2009Many thanks to Justin2, Jason, and Julie for portions of this handout.Using the Xcode debugger Note: this handout refers to Xcode 2.5. The windows for Xcode 3.1 will look slightly diffe
Stanford - CS - 106B
CS106B Winter 2008Handout 13CS106 Library ClassesJanuary 16, 2008Kudos to Julie Zelenski for this fantastic summary of the CS106 utility and container classes.This summer Im going to try something that another lecturer successfully tried last quarter
Stanford - CS - 106B
CS106B Winter 2009Handout 14Electronic SubmissionJanuary 17, 2009This handout was written by Mehran Sahami and updated by Nick Miyake and Jerry Cain.Submission procedures When you submit a completed assignment, you will turn it two versions, a paper
Stanford - CS - 106B
CS106B Winter 2009Handout 15Section Handout 2January 21, 2009Problem 1: Using the Scanner and Stack classes&lt;html&gt;&lt;b&gt;&lt;i&gt;CS106 rules!&lt;/i&gt;&lt;/b&gt;&lt;/html&gt;Web browsers use stacks to track html tags such as &lt;b&gt;, &lt;i&gt; or &lt;html&gt;. Every html tag must be matched b
Stanford - CS - 106B
CS106B Winter 2009Handout 15SSection Solution 2January 21 22, 2009Problem 1: Using the Scanner and Stack classes#include &quot;stack.h&quot; #include &quot;scanner.h&quot; bool ProcessOpenTag(Scanner&amp; scanner, Stack&lt;string&gt;&amp; tagStack) cfw_ string tag = scanner.nextToken
Stanford - CS - 106B
CS106B Winter 2009Handout 17CS106 Library Classes: Take IIJanuary 21, 2009Kudos to Julie Zelenski for this fantastic summary of the CS106 utility and container classes.More on Map Last handout, we noted that the map assumes that keys are of string ty
Stanford - CS - 106B
CS106B Winter 2009Handout 18Introduction to RecursionJanuary 28, 2009Today we'll start working with one of CS106Bs neatest ideas: recursion. Recursion often does the trick whenever the problem to be solved can be broken down into virtually identical (
Stanford - CS - 106B
CS106B Winter 2009Handout 19Section Handout 3January 28, 2009Problem 1: Presidential Speech Tag Cloud Youre handed a Vector&lt;Map&lt;int&gt; &gt; of length 209. The kth item in this Vector is a Map&lt;int&gt; which stores the number of times a nontrivial word appeared
Stanford - CS - 106B
CS106B Winter 2009Handout 19SSection Solution 3January 28 - 30, 2009Solution 1: US Presidential Speech Tag Cloud You may have seen of the web site that inspired this problem. If not, check outhttp:/chir.ag/phernalia/preztags/.This problem was intend
Stanford - CS - 106B
CS106B Winter 2009Handout 20Assignment 3: Recursion Problem SetJanuary 30, 2009This week your task is structured as a problem set, consisting of several small problems to solve in isolation. Recursion is a difficult concept to master and one that is w
Stanford - CS - 106B
CS106B Winter 2009Handout 21Section Handout 4February 4, 2009Problem 1: Towers Of Hanoi Revisited One of the first procedural recursion problems we discussed in lecture was the classic Towers Of Hanoi problem. The recursive solution lists a series of
Stanford - CS - 106B
CS106B Winter 2009Handout 23CS106B Practice MidtermFebruary 6th, 2009Exam Facts: When: Wednesday, February 11th at 7:00 p.m. Where: TBD (probably Dinkelspiel Auditorium, but still waiting for confirmation) Coverage The midterm will test everything up
Stanford - CS - 106B
CS106B Autumn 2009Handout 23SCS106B Practice SolutionFebruary 6th, 2009Solution 1: Acronymsvoid ReadIntoMap(ifstream&amp; in, Map&lt;Vector&lt;string&gt; &gt;&amp; map) cfw_ Scanner s; s.setSpaceOption(Scanner:IgnoreSpaces); while (true) cfw_ string line; getline(in, li
Stanford - CS - 106B
CS106B Winter 2009Handout 29Section Handout 6February 18, 2009Problem 1: Removing Duplicates Write a function RemoveDuplicates that given a linked list will remove and free the second of all neighboring duplicates found in the list. If the incoming li
Stanford - CS - 106B
CS106B Winter 2009Handout 29SSection Solution 6February 18-20, 2009Problem 1: Removing Duplicatesvoid RemoveDuplicates(node *list) cfw_ for (node *cur = list; cur != NULL; cur = if (cur-&gt;next != NULL &amp; cur-&gt;value = node *duplicate = cur-&gt;next; cur-&gt;n
Old Dominion - ENGLISH - 12
www.GetPedia.com*More than 150,000 articles in the search database *Learn how almost everything worksEnglish Vocabulary in UseCAMBRIDGEU NIVERSITY PRESSPUBLISHED BY T H E PRESS SYNDICATE O F T H E UNIVERSITY OF CAMBRIDGET he Pitt Building, Trumpingt
Old Dominion - ENGLISH - 15
New New Headway Intermediate Testsea e a ho TeachHea tocopi lass o p da ar omfe un l, stndt a s ho iada o p da ar somfe un l, stndt a C mater tte.tion i riadati is a e c mate tte. on Casstaught an e co short staught anduexplained thoroughly, Cas rse zer
Golden West - BIOL 200 - BIOL 200
Summer 2009 Bio 200Pharmacology: An Introduction to Basic Drug GroupsCourse Objective Students will study the classication of medications and basic principles of pharmacology from legislation and pharmacokinetics through receptor theory, pharmacodynamic
Golden West - BIOL 200 - BIOL 200
DrugsofthePeripheralNervousSystemNervousSystems2DivisionsCentralBrain SpinalCordPeripheralVoluntary Involuntary AutonomicSympathetic ParasympatheticEffectorCellsofthe PeripheralNervousSystemVoluntarySkeletalMuscleAutonomicCardiacMuscle SmoothMu
Golden West - BIOL 200 - BIOL 200
Unit 10Serums, Vaccines &amp; HormonesTypes of ImmunityNatural (Inborn) ActiveMake Own AntibodiesAcquiredPassiveGiven Preformed AntibodiesExposureInjection Vaccine ToxoidMother to FetusSerums(Gamma Globulins)Diabetes Mellitus Characterized by el
Golden West - BIOL 200 - BIOL 200
Unit 9DiureticsFiltrationReabsorption Secretion ExcretionDCT: Aldosterone PCT: 100% Nutrients Reabsorbed`Clor HCO3-K+ o r H +Powerful Reabsorption: Cl- &amp; Na+Collecting Tubule: Loop of Henle:Counter Current Mechanism Sets up ability to concentrat
Golden West - BIOL 200 - BIOL 200
Unit 8Eye, Skin &amp; AntimicrobialsWide Angle1Narrow AngleThree major types of glaucoma and basic treatment: Congenital Glaucoma surgery required Primary Glaucoma Narrow angle (also called acute congestive) cause: poor drainage because of position of
Golden West - BIOL 200 - BIOL 200
Unit 7Respiratory, Antihistaminic &amp; GI DrugsAsthma: Bronchoconstriction Increased mucus productionManaging the Airway Drugs to open the airway Drugs to treat the inflammation Decrease the airway remodeling Remodeling describes the permanent, negativ
Golden West - BIOL 200 - BIOL 200
Drugs of the Central Nerous SystemStimulation Increases: Convulsions or Seizures Sensory Acuity Motor Activity Tremors &amp; Hallucinations Anxiety Euphoria Normal -Neutral Sedation (Drowsy) Hypnosis (Sleep) General Anesthesia Coma DeathDeathDepression Inh
Golden West - BIOL 200 - BIOL 200
Unit 5Drugs of the Cardiovascular SystemCardiotonic drugs Drugs that increase the strength of the heart. Drugs for a failing heart.The heart becomes weaker as a pump. Can happen over many years or rapidly in response to injury Goals for treatment: in
Golden West - BIOL 200 - BIOL 200
Lecture 2How effective is the drug at producing a pharmacologic response. How well does it relief symptoms Not concerned with how much a person needs totake to get the effectMaximum effect of the drugThe amount of the drug necessary to produce a phar
Golden West - BIOL 200 - BIOL 200
Welcome to Pharmacolgy Biology 200Petitioners will be added at the end of lectureDr. Kate EganOffice: HS 115 Phone: 714.892.7711 ext. 51125 Hours: Tuesday 2:15-3:15 / 5:30-6:30 PM Wednesday 6:00 - 7:00 PM or by appointment Email: cegan@gwc.cccd.edu Cou
Golden West - BIOL 200 - BIOL 200
PHARMACOLOGY: Homework AssignmentDue: Worth: Time:PRINT NAME:_ Three ID#:_Last Class Meeting Before Final Exam - Will not be accepted late. 5 points Do not spend more than 30 minutesUSE: DRUG FACTS AND COMPARISONS1. Use the Table of Contents of Drug
Golden West - BIOL 200 - BIOL 200
PRINT NAME: _ ID#:_ PHARMACOLOGY: HOMEWORK 2 Due: Meeting When Beginning Unit 7 - Will not be accepted late. Worth: 5 points Time: Do not spend more than 30 minutesUSE: DRUG FACTS AND COMPARISONS1. Use the Table of Contents from the front of Drug Facts
Golden West - BIOL 200 - BIOL 200
Print Name:_ Student ID #:_ Pharmacology: Homework Assignment One Due: March 4, 2009 5 pts Look up a drug of your choice in 3 a Physicians Desk Reference Book, a Drug Facts &amp; Comparisons Book and another drug reference book of your choice. Goal of the ass
Golden West - BIOL 200 - BIOL 200
Pharmacology Final Study OutlineUnit 1-3 (8) Understand Ionization and how it pertains to the movement of a drug Know the difference between potency and efficacy Review Drug Schedule/ prescription writing procedures How are drugs namedtrade names, generi
Golden West - BIOL 200 - BIOL 200
Name:_ ID #:_ Bio 200- Pharmacology Additional Extra Credit Assignment Due 5/20 NO LATE ASSIGNMENTS WILL BE ACCEPTED Write on this sheet of paper (you can use both sides if needed) Research the mechanism of action of the diuretics furosemide (Lasix) and s
Golden West - BIOL 200 - BIOL 200
Pharmacology Extra Credit AssignmentWorth 5 points Due Meeting Before Final Exam Accepted Earlier but not laterAssignment:1. Read one article in a professional journal which has been published within the past 15 months. This includes major science maga
Golden West - BIOL 200 - BIOL 200
Pharmacology Exam 3 Review (Units 6-8) Unit 6 Drugs of the CNS Memorize the Continum Chart Understand the 2 types of tolerance Factors contributing to drug dependence CNS Stimulants how do they work? What are the main types we talked about in class the ma
Golden West - BIOL 200 - BIOL 200
EXAM 2 REVIEW Unit 4 Drugs of the Peripheral Nervous System What are preganglionic and postganglionic neurons and where are they found? How many efferent neurons in the SNS, PNS, voluntary portion of the nervous system What are the main receptors we talke
Golden West - BIOL 200 - BIOL 200
Outline of Central Nervous System DrugsDirections: MEMORIZE THIS A. CNS Stimulants - increase activity of ALL parts of the CNS 1. Amphetamines and related compounds 2. Xanthines (including caffeine, theobromine, and theophylline) 3. Cocaine and related l
Monmouth IL - CAAM - 236
EE236A (Fall 2007-08)Lecture 13 Convergence analysis of the barrier method complexity analysis of the barrier method convergence analysis of Newtons method choice of update parameter bound on the total number of Newton iterations initialization131Comp
Monmouth IL - CAAM - 236
EE236A (Fall 2007-08)Lecture 14 Primal-dual interior-point methods primal-dual path-following Mehrotras corrector step computing the search directions141Central path and complementary slacknesss + Ax b = 0 AT z + c = 0 zisi = 1/t, z 0, i = 1, . . . ,
Monmouth IL - CAAM - 236
EE236A (Fall 2007-08)Lecture 15 Self-dual formulations initialization and infeasibility detection skew-symmetric LPs homogeneous self-dual formulation self-dual formulation151Solution of an LPgiven a pair of primal and dual LPs minimize cT x subject
Monmouth IL - CAAM - 236
EE236A (Fall 2007-08)Lecture 16 Large-scale linear programming cutting-plane method Benders decomposition delayed column generation Dantzig-Wolfe decomposition161Cutting-plane methodminimize cT x subject to Ax b A Rmn, m n general idea: solve sequenc
Monmouth IL - CAAM - 236
EE236A (Fall 2007-08)Lecture 17 Integer linear programming integer linear programming, 0-1 linear programming a few basic facts branch-and-bound171Denitioninteger linear program (ILP) minimize cT x subject to Ax b, x ZncGx = dmixed integer linear
Monmouth IL - CAAM - 236
EE236A (Fall 2007-08)Lecture 1 Introduction and overview linear programming example from optimal control example from combinatorial optimization history course topics software11Linear program (LP)nminimizej =1 ncj xj aij xj bi,j =1 nsubject toi
Monmouth IL - CAAM - 236
EE236A (Fall 2007-08)Lecture 2 Linear inequalities vectors inner products and norms linear equalities and hyperplanes linear inequalities and halfspaces polyhedra21Vectors(column) vector x Rn: x1 x x = .2 . xn xi R: ith component or element of x al
Monmouth IL - CAAM - 236
EE236A (Fall 2007-08)Lecture 3 Geometry of linear programming subspaces and ane sets, independent vectors matrices, range and nullspace, rank, inverse polyhedron in inequality form extreme points the optimal set of a linear program31SubspacesS Rn (S
Monmouth IL - CAAM - 236
EE236A (Fall 2007-08)Lecture 4 The linear programming problem variants of the linear programming problem LP feasibility problem examples and some general applications linear-fractional programming41Variants of the linear programming problemgeneral fo
Monmouth IL - CAAM - 236
EE236A (Fall 2007-08)Lecture 5 Structural optimization minimum weight truss design truss topology design limit analysis design with minimum number of bars51Truss m bars with lengths li and cross-sectional areas xi N nodes; nodes 1, . . . , n are free