CS 541 Algorithms and Programs. Exam 2 Solutions. Jonathan Turner 11/8/01

Similar documents
Jonathan Turner Exam 2-10/28/03

Jonathan Turner Exam 2-12/4/03

Combinatorial Optimization

Library Support. Netlist Conditioning. Observe Point Assessment. Vector Generation/Simulation. Vector Compression. Vector Writing

Design and Analysis of Algorithms (Autumn 2017)

1 Finite Automata and Regular Expressions

Graphs: Paths, trees and flows

Section P.1 Notes Page 1 Section P.1 Precalculus and Trigonometry Review

Single Correct Type. cos z + k, then the value of k equals. dx = 2 dz. (a) 1 (b) 0 (c)1 (d) 2 (code-v2t3paq10) l (c) ( l ) x.

A Study of the Solutions of the Lotka Volterra. Prey Predator System Using Perturbation. Technique

Mathcad Lecture #4 In-class Worksheet Vectors and Matrices 1 (Basics)

CSE 421 Algorithms. Warmup. Dijkstra s Algorithm. Single Source Shortest Path Problem. Construct Shortest Path Tree from s

Lecture 21 : Graphene Bandstructure

3.4 Repeated Roots; Reduction of Order

Math 266, Practice Midterm Exam 2

FL/VAL ~RA1::1. Professor INTERVI of. Professor It Fr recru. sor Social,, first of all, was. Sys SDC? Yes, as a. was a. assumee.

Shortest Paths. CSE 421 Algorithms. Bottleneck Shortest Path. Negative Cost Edge Preview. Compute the bottleneck shortest paths

Transformations. Ordered set of numbers: (1,2,3,4) Example: (x,y,z) coordinates of pt in space. Vectors

RUTH. land_of_israel: the *country *which God gave to his people in the *Old_Testament. [*map # 2]

Chapter 5 The Laplace Transform. x(t) input y(t) output Dynamic System

INTERQUARTILE RANGE. I can calculate variabilityinterquartile Range and Mean. Absolute Deviation

Final Exam : Solutions

DEPARTMENT OF ELECTRICAL &ELECTRONICS ENGINEERING SIGNALS AND SYSTEMS. Assoc. Prof. Dr. Burak Kelleci. Spring 2018

More on FT. Lecture 10 4CT.5 3CT.3-5,7,8. BME 333 Biomedical Signals and Systems - J.Schesser

Laplace Transform. National Chiao Tung University Chun-Jen Tsai 10/19/2011

Part 3 System Identification

The Procedure Abstraction Part II: Symbol Tables and Activation Records

Chapter 12 Introduction To The Laplace Transform

Fourier Series and Parseval s Relation Çağatay Candan Dec. 22, 2013

x, x, e are not periodic. Properties of periodic function: 1. For any integer n,

b. How many ternary words of length 23 with eight 0 s, nine 1 s and six 2 s?

Poisson process Markov process

Transfer function and the Laplace transformation

REPETITION before the exam PART 2, Transform Methods. Laplace transforms: τ dτ. L1. Derive the formulas : L2. Find the Laplace transform F(s) if.

LIVESTOCK & AGRICULTURE

Factors Success op Ten Critical T the exactly what wonder may you referenced, being questions different the all With success critical ten top the of l

Solutions to assignment 3

Math 61 : Discrete Structures Final Exam Instructor: Ciprian Manolescu. You have 180 minutes.

Instructors Solution for Assignment 3 Chapter 3: Time Domain Analysis of LTIC Systems

3+<6,&6([DP. September 29, SID (last 5 digits): --

Eager st-ordering. Universität Konstanz. Ulrik Brandes. Konstanzer Schriften in Mathematik und Informatik Nr. 171, April 2002 ISSN

ADDENDUM. The following addendum becomes a part of the above referenced bid. All other terms and conditions remain in effect, unchanged.

Appendix. In the absence of default risk, the benefit of the tax shield due to debt financing by the firm is 1 C E C

Relation between Fourier Series and Transform

Functions and Graphs 1. (a) (b) (c) (f) (e) (d) 2. (a) (b) (c) (d)

CHEMISTRY 047 STUDY PACKAGE

Rectangular Waveguides

Eager st-ordering. 1 Introduction. Ulrik Brandes

Midterm. Answer Key. 1. Give a short explanation of the following terms.

Boyce/DiPrima 9 th ed, Ch 2.1: Linear Equations; Method of Integrating Factors

2 T. or T. DSP First, 2/e. This Lecture: Lecture 7C Fourier Series Examples: Appendix C, Section C-2 Various Fourier Series

Maximum Flow. Flow Graph

Elementary Differential Equations and Boundary Value Problems

How to Order. Description. Metric thread (M5) Rc NPT G

K x,y f x dx is called the integral transform of f(x). The function

ENJOY ALL OF YOUR SWEET MOMENTS NATURALLY

A Simple Code Generator. Code generation Algorithm. Register and Address Descriptors. Example 3/31/2008. Code Generation

CSC 373: Algorithm Design and Analysis Lecture 9

MEDWAY SPORTS DEVELOPMENT

CIVL 8/ D Boundary Value Problems - Rectangular Elements 1/7

Physics 2A HW #3 Solutions

CATAVASII LA NAȘTEREA DOMNULUI DUMNEZEU ȘI MÂNTUITORULUI NOSTRU, IISUS HRISTOS. CÂNTAREA I-A. Ήχος Πα. to os se e e na aș te e e slă ă ă vi i i i i

Verifcaton. Staemnt. Treasur( Oficeholdr, TREASU, Terminato) reasonbl. informat. aplicbe: DIFERNT) knowledg. Contrled Comite: schedul.

A L A BA M A L A W R E V IE W

CPSC 211 Data Structures & Implementations (c) Texas A&M University [ 259] B-Trees

Trader Horn at Strand This Week

UNSTEADY HEAT TRANSFER

176 5 t h Fl oo r. 337 P o ly me r Ma te ri al s

QUESTIONS BEGIN HERE!

Distributed Algorithms for Secure Multipath Routing in Attack-Resistant Networks

Behaviors and Attitudes

Beechwood Music Department Staff

Bipartite Matching. Matching. Bipartite Matching. Maxflow Formulation

Having a glimpse of some of the possibilities for solutions of linear systems, we move to methods of finding these solutions. The basic idea we shall

Boyce/DiPrima 9 th ed, Ch 7.8: Repeated Eigenvalues

LAPLACE TRANSFORMS. 1. Basic transforms

, each of which is a tree, and whose roots r 1. , respectively, are children of r. Data Structures & File Management

Phonics Bingo Ladders

The model proposed by Vasicek in 1977 is a yield-based one-factor equilibrium model given by the dynamic

ARC 202L. Not e s : I n s t r u c t o r s : D e J a r n e t t, L i n, O r t e n b e r g, P a n g, P r i t c h a r d - S c h m i t z b e r g e r

Math 3301 Homework Set 6 Solutions 10 Points. = +. The guess for the particular P ( ) ( ) ( ) ( ) ( ) ( ) ( ) cos 2 t : 4D= 2

Equations and Boundary Value Problems

16.unified Introduction to Computers and Programming. SOLUTIONS to Examination 4/30/04 9:05am - 10:00am

The Laplace Transform

EE Control Systems LECTURE 11

P a g e 3 6 of R e p o r t P B 4 / 0 9

Flow Networks Alon Efrat Slides courtesy of Charles Leiserson with small changes by Carola Wenk. Flow networks. Flow networks CS 445

Exam 1 Solution. CS 542 Advanced Data Structures and Algorithms 2/14/2013

Similarity Search. The Binary Branch Distance. Nikolaus Augsten.

MAT3707. Tutorial letter 201/1/2017 DISCRETE MATHEMATICS: COMBINATORICS. Semester 1. Department of Mathematical Sciences MAT3707/201/1/2017

PHYSICS 211 MIDTERM I 21 April 2004

2D Motion WS. A horizontally launched projectile s initial vertical velocity is zero. Solve the following problems with this information.

Shortest Path With Negative Weights

5/1/2018. Huffman Coding Trees. Huffman Coding Trees. Huffman Coding Trees. Huffman Coding Trees. Huffman Coding Trees. Huffman Coding Trees

Labeling Problem & Graph-Based Solution

1a.- Solution: 1a.- (5 points) Plot ONLY three full periods of the square wave MUST include the principal region.

Advanced Microeconomics II. Lijun Pan Nagoya University

EEE 303: Signals and Linear Systems

RIM= City-County Building, Suite 104 NE INV= Floor= CP #CP004 TOP SE BOLT LP BASE N= E= ELEV=858.

1. Be a nurse for 2. Practice a Hazard hunt 4. ABCs of life do. 7. Build a pasta sk

Transcription:

CS 1 Algorim nd Progrm Exm Soluion Jonn Turnr 11/8/01 B n nd oni, u ompl. 1. (10 poin). Conidr vrion of or p prolm wi mulipliiv o. In i form of prolm, lng of p i produ of dg lng, rr n um. Explin ow or p lgorim n modifid o ndl mulipliiv o. W i impliion of ving poiiv dg o r l n 1? On wy o do i i o rpl originl o y ir logrim nd n u ndrd or p lgorim on grp wi rnformd o. T rul din mu n rnformd k o giv mulipliiv din. Sin logrim of produ i qul o um of logrim, i produr yild or mulipliiv p. Alrnivly, on n modify originl lgorim o rpl xprion of form di(u) + lng(u,v) wi di(u) * lng(u,v) in or p lgorim. T orrn of i follow from logrim rnformion. Poiiv dg o l n 1 rdu p lng nd v m ff ngiv dg lng in ndrd prolm. If u dg r prn, Dijkr lgorim nno ud.. (10 poin) Inr flow in nwork own low y finding n ugmning p uing din lling lgorim. Wnvr r r mulipl dmiil dg vill for xnding p, u on wo or ndpoin om fir in lpil ordr. B ur o ow ow din ll ng, wll owing ugmning p found. 1 6,, f 8, 1,0,0,0 d 0 7, 6, 1,0 7, g,, 1 T ugmning p i own in old nd modifid din ll r lo own in old. T ugmning p ridul piy of 1. 6,, f 8, 1,0,0,1 d 0 7, 6, 1,1 7,6 g, - 1 -, 1

. (1 poin) T piur low ow n implmnion of dynmi r, uing linkd p rprnd y inry r r. Drw ul r i rprn (wi vrx o). Auming ul r i ing ud in mximum flow ompuion, w i ridul piy of p from o in ul r. Wi dg om urd if mximum poil moun of flow i ddd o i p? min, o, 10 1,0 0,1 i g k,1,0 d 0,0 96, m, 1,0 f 0,0 g n 0,0 i,0 d 6 T ul r ppr rig. T dg from d o i only on om urd fr uni of flow r ddd o p kfd. 8 n m 7 f k 6 6 - -

. (10 poin) T diffrnil o rprnion ud y p d ruur rquir min nd o updd during roion oprion. Sow wo quion low r orr. o, min x,1 z 0,1 1,1, o, min 1,1 z, x 1, o'(x) = o(x) min'(x) o'(x) = o(x) mino'(x) = o(x) (mino'(z) + min'(x)) = o(x) mino(x) min'(x) = o(x) min'(x) min'() = min() min'(x) + min(z) mino'() = mino'(z) + min'(x) + min'() min'() = mino'() mino'(z) min'(x) = mino() mino(x) min'(x) = mino(x) + min(z) + min() mino(x) min'(x) = min(z) + min() min'(x) - -

. (1 poin) W v own Dini lgorim wi or p ugmnion k O(mn)=O(n ) im o find loking flow in lvl grp. Sow i lo k Ω(n ) im in wor-, y owing for om onn C nd ny vlu of n, r i lvl grp on wi Dini lgorim k l Cn im. dg pii qul o n. dg pii qul o n. n n/ vri nd dg pii qul o n. ompl ipri grp wi n/ vri nd dg pii ll qul o 1. T ndrd vrion of Dini lgorim will find n/ p in i lvl grp nd for p i will rr p lf, mning i will k Ω(n ) im ovrll. In onr, Slor-Trjn vrion of Dini lgorim will run in O(n log n) im, in i n ffivly rvr long p lf in O(log n) im uing dynmi r d ruur. - -

6. (10 poin) Sow wv mod run fr on uni nwork n on gnrl nwork. How do wv mod ompr o ndrd vrion of Dini lgorim on uni nwork? From nlyi of Dini lgorim on uni nwork, w know numr of loking p rquird o find mximum flow i O(n 1/ ). Ti ppli o wv mod wll. Sin wv mod find loking flow in O(n ) im, ovrll running im i O(n / ), wi i r n O(n ) for gnrl grp, u no good O(mn 1/ ) ndrd vrion of Dini lgorim iv on uni nwork. 7. (1 poin). Conidr d ruur minin ollion of li of im, wi im ppring on on li, nd uppor following oprion: on(l 1, L ) Comin li L 1 wi li L. op(x) Spr li onining x ino wo li, on onining ll lmn prding x nd on onining x nd ll lmn following i. rvr(l) Rvr ordr of lmn in li L. il(l) Rurn l lmn of li onining L. T oprion n implmnd ffiinly uing lf-djuing inry r r o rprn li, upplmnd wi flip i nod. If um of flip i on p from nod o roo of r i vn, n lf ur of nod x onin im ppr for x in i li nd rig ur onin im ppr fr x in i li. If um i odd, lf ur onin im ppr fr x in i li nd rig ur onin im ppr for i. Fill in C++ od ndd o implmn rvr, il nd on oprion. You nd no ow ow ro oprion r modifid o ndl flip i. l li { in n; // li dfind on im 1..n ru nod { in flip; // flip i im prn; // prn in r r im l; // lf ild im r; // rig ild } *v; // vor of nod puli:... im li::rvr(li L){ v[l].flip =!v[l].flip; - -

im li::il(li L) { in f; if (L == Null) rurn Null; f = v[l].flip & 1; wil (1) { if (f == 0 && v[l].r Null) { L = v[l].r; f = (f + v[l].flip) & 1; } l if (f == 1 && v[l].l Null) { L = v[l].l; f = (f + v[l].flip) & 1; } l rurn ply(l); } im li::on(li L1, li L) { in ; if (L1 == Null) rurn L; l if (L == Null) rurn L1; = il(l1); if (v[].flip == 0) v[].r = L; l { L.flip = (L.flip + 1) & 1; v[].l = L; } v[l].prn = L1; rurn L1; - 6 -