Homework Solutions Unit 4: Chapter 22 CMPSC 465

Similar documents
Chapter 30: Magnetic Fields Due to Currents

Solutions to Problems: Chapter 7

Standardized Coefficients

Module Availability at Regent s School of Drama, Film and Media Autumn 2016 and Spring 2017 *subject to change*

Worked Examples. v max =?

Gross Trade Accounting, Cross Country Production Sharing and Global Value-Chain

Chapter 13 Fluids. Use the definition of density to express the mass of the gold sphere: The mass of the copper sphere is given by:

The Essence of the Electromagnetic Wave is Not Energy

Multiple choice questions [70 points]

Decision-Driven Fixed Income Attribution

Effect of Unemployment Insurance Tax On Wages and Employment: A Partial Equilibrium Analysis

Parameter Identification of DC Motors

10. Collisions. Before During After

DSC Baseline Improvements Obtained by a New Heat Flow Measurement Technique

Week 3-4: Permutations and Combinations

The Role of Gravity in Orbital Motion

Semipartial (Part) and Partial Correlation

Problem Set # 9 Solutions

Integrating Net2 with an intruder alarm system

Top K Nearest Keyword Search on Large Graphs

Optimizing Supply Chain Collaboration Based on Negotiation and Bargain Power for Single Retailer And Single Supplier

Things to Remember. r Complete all of the sections on the Retirement Benefit Options form that apply to your request.

Chapter 3 Savings, Present Value and Ricardian Equivalence

Using Model Checking to Analyze Network Vulnerabilities

AP Physics Electromagnetic Wrap Up

Small Hydropower Plant with variable speed PM generator

Scal abil it y of ANSYS 16 applicat ions and Hardware select ion.

Incline and Friction Examples

Armored Car Insurance Application

2. TRIGONOMETRIC FUNCTIONS OF GENERAL ANGLES

UNIT CIRCLE TRIGONOMETRY

How To Change V1 Programming

Optimal Pricing Decision and Assessing Factors in. Closed-Loop Supply Chain

Experiment 6: Centripetal Force

Graphs of Equations. A coordinate system is a way to graphically show the relationship between 2 quantities.

An Introduction to Omega

Mechanics 1: Work, Power and Kinetic Energy

Definitions and terminology

Interface Design for Rationally Clocked GALS Systems

Requirements and Framework of VPN-oriented Data Center Services

How To Use A Network On A Network With A Powerline (Lan) On A Pcode (Lan On Alan) (Lan For Acedo) (Moe) (Omo) On An Ipo) Or Ipo (

Chapter 1: Introduction BELSORP analysis program Required computer environment... 8

CONCEPTUAL FRAMEWORK FOR DEVELOPING AND VERIFICATION OF ATTRIBUTION MODELS. ARITHMETIC ATTRIBUTION MODELS

LTI, SAML, and Federated ID - Oh My!

(1) continuity equation: 0. momentum equation: u v g (2) u x. 1 a

Fast FPT-algorithms for cleaning grids

YARN PROPERTIES MEASUREMENT: AN OPTICAL APPROACH

Magnetic Field and Magnetic Forces. Young and Freedman Chapter 27

Financing Terms in the EOQ Model

The Binomial Distribution

Purchase and rental subsidies in durable-good oligopolies* 1

VISCOSITY OF BIO-DIESEL FUELS

MSc Financial Economics: International Finance. Bubbles in the Foreign Exchange Market. Anne Sibert. Revised Spring Contents

CRRC-1 Method #1: Standard Practice for Measuring Solar Reflectance of a Flat, Opaque, and Heterogeneous Surface Using a Portable Solar Reflectometer

Lecture 16: Color and Intensity. and he made him a coat of many colours. Genesis 37:3

Figure 2. So it is very likely that the Babylonians attributed 60 units to each side of the hexagon. Its resulting perimeter would then be 360!

Questions & Answers Chapter 10 Software Reliability Prediction, Allocation and Demonstration Testing

Modelling and simulation of a signal injection self-sensored drive

Chapter 22. Outside a uniformly charged sphere, the field looks like that of a point charge at the center of the sphere.

Skills Needed for Success in Calculus 1

How to SYSPREP a Windows 7 Pro corporate PC setup so you can image it for use on future PCs

Reduced Pattern Training Based on Task Decomposition Using Pattern Distributor

Summary: Vectors. This theorem is used to find any points (or position vectors) on a given line (direction vector). Two ways RT can be applied:

THE PRINCIPLE OF THE ACTIVE JMC SCATTERER. Seppo Uosukainen

PHYSICS 111 HOMEWORK SOLUTION #13. May 1, 2013

Space Vector Modulated Direct Torque Controlled (DTC SVM) Inverter Fed Induction Motor Drive

The LCOE is defined as the energy price ($ per unit of energy output) for which the Net Present Value of the investment is zero.

How to create RAID 1 mirroring with a hard disk that already has data or an operating system on it

CANCER, HEART ATTACK OR STROKE CLAIM FORM

Over-encryption: Management of Access Control Evolution on Outsourced Data

LATIN SQUARE DESIGN (LS) -With the Latin Square design you are able to control variation in two directions.

Saturated and weakly saturated hypergraphs

AP Physics Gravity and Circular Motion

Faithful Comptroller s Handbook

Cloud Service Reliability: Modeling and Analysis

How to create a default user profile in Windows 7

Chapter 19: Electric Charges, Forces, and Fields ( ) ( 6 )( 6

How to recover your Exchange 2003/2007 mailboxes and s if all you have available are your PRIV1.EDB and PRIV1.STM Information Store database

How Much Should a Firm Borrow. Effect of tax shields. Capital Structure Theory. Capital Structure & Corporate Taxes

NUCLEAR MAGNETIC RESONANCE

Uncertain Version Control in Open Collaborative Editing of Tree-Structured Documents

Chapter 11: Aggregate Demand II, Applying the IS-LM Model Th LM t

Solving Systems of Linear Equations With Row Reductions to Echelon Form On Augmented Matrices. Paul A. Trogdon Cary High School Cary, North Carolina

Mechanics 1: Motion in a Central Force Field

Ethernet-based and function-independent vehicle control-platform

Transmittal 47 Date: FEBRUARY 24, 2006

Episode 401: Newton s law of universal gravitation

Continuous Compounding and Annualization

DNS: Domain Name System

Gauss Law. Physics 231 Lecture 2-1

CHAPTER 10 Aggregate Demand I

Lab #7: Energy Conservation

The University of Toledo Soil Mechanics Laboratory

P/ACE MDQ Basic Training Workbook

PAN STABILITY TESTING OF DC CIRCUITS USING VARIATIONAL METHODS XVIII - SPETO pod patronatem. Summary

SOLUTIONS TO CONCEPTS CHAPTER 16

SUPPLY CHAIN STRUCTURES ON THE INTERNET and the role of marketing-operations interaction 1

The force between electric charges. Comparing gravity and the interaction between charges. Coulomb s Law. Forces between two charges

Coordinate Systems L. M. Kalnins, March 2009

4a 4ab b (count number of places from first non-zero digit to

Transcription:

Homeok Solution Unit : Chapte CMPSC 65 Diclaime: Thi i a daft of olution that ha been pepaed b the TA and the intucto make no guaantee that olution peented hee contain the leel of detail that ould be expected on an exam. An eo o explanation ou find unclea hould be epoted to eithe of the TA fo coection fit. Execie.- Gien an adjacenc-lit epeentation of a diected gaph, ho long doe it take to compute the out-degee of ee etex? Ho long doe it take to compute the in-degee? Gien an adjacenc-lit epeentation Adj of a diected gaph, the out-degee of a etex u i equal to the length of Adj[u], and the um of the length of all the adjacenc lit in Adj i E. Thu the time to compute the out-degee of ee etex i Θ ( V + E ). The in-degee of a etex u i equal to the numbe of time it appea in all the lit in Adj. If e each all the lit fo each etex, the time to compute the in-degee of ee etex i Θ ( V E ). (Altenatiel, e can allocate an aa T of ize V and initialize it entie to zeo. Then e onl need to can the lit in Adj once, incementing T [u] hen e ee u in the lit. The alue in T ill be the in-degee of ee etex. Thi can be done in Θ ( V + E ) time ith Θ ( V ) additional toage.) Page of 8 PSU CMPSC 65 Sping

Execie.- Gie an adjacenc-lit epeentation fo a complete bina tee on 7 etice. Gie an equialent adjacenc-matix epeentation. Aume that etice ae numbeed fom to 7 a in a bina heap. A complete bina tee look like: 5 6 7 An adjacenc-lit epeentation of thi tee i hon belo: 5 6 7 5 6 7 An equialent adjacenc-matix epeentation of thi tee i hon belo: 5 6 7 5 6 7 Page of 8 PSU CMPSC 65 Sping

Execie.- Sho the dit and ped alue that eult fom unning beadth-fit each on the diected gaph belo, uing etex a the ouce. 5 6.ped 5 6 (a).ped 5.ped (d).ped :5 6.ped 5.ped (b).ped 6.ped 5 6.ped.ped : 5.ped.ped :5 (e) 6.ped.ped 5.ped.ped :5 6.ped 6.ped.ped : 5.ped.ped :5 6.ped (c) (f) The pocedue of the beadth-fit each i hon aboe. Fom the eult, e can ee that: Node Ped dit NIL 5 6 5 NIL Page of 8 PSU CMPSC 65 Sping

Execie.- Sho the dit and ped alue that eult fom unning beadth-fit each on the undiected gaph belo, uing etex u a the ouce. t u x (a) t (f).ped : x u.ped (b) (g).ped :.ped : t x.ped (c) (h).ped :.ped :.ped x 5.ped.ped : 5 (d) (i).ped :.ped :.ped 5.ped.ped : (e).ped Page of 8 PSU CMPSC 65 Sping

The pocedue of the beadth-fit each i hon aboe. Fom the eult, e can ee that: Node Ped dit u NIL t u x u u t 5 Execie.- Make a -b- chat ith o and column label WHITE, GRAY, and BLACK. In each cell (i, j), indicate hethe, at an point duing a depth-fit each of diected gaph, thee can be an edge fom a etex of colo i to a etex of colo j. Fo each poible edge, indicate hat edge tpe it can be. Make a econd uch chat fo depth-fit each of an undiected gaph. Diected gaph: WHITE GRAY BLACK WHITE tee, back, foad, and co back and co co GRAY tee and foad tee, foad, back tee, foad, and co BLACK back and co tee, foad, back and co Undiected gaph: WHITE GRAY BLACK WHITE tee and back tee and back GRAY tee and back tee and back tee and back BLACK tee and back tee and back Execie.- Sho ho depth-fit each ok on the gaph of Figue.6. Aume that the fo loop of line 5 7 of the DFS pocedue conide the etice in alphabetical ode, and aume that each adjacenc lit i odeed alphabeticall. Sho the dicoe and finihing time fo each etex, and ho the claification of each edge. Page 5 of 8 PSU CMPSC 65 Sping

The dicoe and finihing time fo each etex ae hon in the figue belo:,6 7,,7 8,5 8,9,6,5 9,,, Tee edge: (q, ), (, ), (, ), (q, t), (t, x), (x, z), (t, ), (, u) Back edge: (, ), (z, x), (, q) Foad edge: (q, ) Co edge: (, ), (u, ) Execie.- Sho the paenthei tuctue of the depth-fit each of Figue.. Figue. (p) Execie.-7 Reite the pocedue DFS, uing a tack to eliminate ecuion. Aume that the tack ha folloing opeation: PUSH(S, ) puhe into the tack; POP(S) etun the top of the tack and emoe it; TOP(S) etun the top of the tack ithout emoing it. Page 6 of 8 PSU CMPSC 65 Sping

Denote an empt tack b EMPTY. Then the peudocode of thi algoithm become a follo: DFS_STACK (G, ) fo each etex u V(G) {} { u.colo = WHITE = NIL } time = S = EMPTY time = time +.t d = time.colo = GRAY PUSH(S, ) hile S!= EMPTY { t = TOP(S) if V(G).Adj[t].t..colo == WHITE // adjacenc lit han t been full examined {.ped = t time = time +.t d = time.colo = GRAY PUSH(S, ) } ele // adjacenc lit ha been full examined } { } t = POP(S) time = time +.t f = time.colo = BLACK Execie.- Sho the odeing of etice poduced b TOPOLGICAL-SORT hen it i un on the dag of Figue.8, unde the aumption of Execie.-. Accoding to the aumption of Execie.-, the fo loop of line 5 7 of the DFS pocedue Page 7 of 8 PSU CMPSC 65 Sping

conide the etice in alphabetical ode, and that each adjacenc lit i odeed alphabeticall. DFS on Figue.8: / /6 /5 6/9 /5 7/8 / / 7/8 /7 / 5/6 9/8 / Odeing of etice: Execie.- Gie a linea-time algoithm that take a input a diected acclic gaph G = (V, E) and to etice and t, and etun the numbe of imple path fom to t in G. Fo example, the diected acclic gaph of Figue.8 contain exactl fou imple path fom etex p to etex : po, po, po, and p. (You algoithm need onl to count the imple path, not lit them.) Add a field to the etex epeentation to hold an intege count. Initiall, et etex t count to and othe etice count to. Stat unning DFS ith a the tat etex. When t i dicoeed, it hould be immediatel maked a finihed (BLACK), ithout futhe poceing tating fom it. Subequentl, each time DFS finihe a etex, et count to the um of the count of all etice adjacent to. When DFS finihe etex, top and etun the count computed fo. Page 8 of 8 PSU CMPSC 65 Sping