Name: 2 Useful Formulas Pn i=1 i = nèn+1è 2 Pn i=1 xi = xn+1,1 x,1 P Pn 1 =lnn + Oè1è 1 i=1 i i=0 = ixi x è1,xè 2 e x =1+x + x2 + x 3 2! 3! + ::: lim

Similar documents
PART I. Answer each of the following. è1è Let! u = h2;,1;,2i and! v = h3; 1;,1i. Calculate: èaè! u, 2! v èbè the dot product of! u and! v ècè! u æ! v

rate name People Consult Topics name rate name People Consult Topics name

Data Structure and Algorithm Homework #5 Due: 2:00pm, Thursday, May 31, 2012 TA === Homework submission instructions ===

Math 241: Calculus III Final Exam è300 points totalè Show All Work Name This test consists of 2 parts. There are 10 problems in Part I, each worth 18

19.2 View Serializability. Recall our discussion in Section?? of how our true goal in the design of a

Graph Algorithms (part 3 of CSC 282),

SUGGESTION : read all the questions and their values before you start.

Fundamental Algorithms CSCI-GA /Summer Solution to Homework 8

END-TERM EXAMINATION

Exam 3 Practice Problems

Inænitely Long Walks on 2-colored Graphs Which Don't Cover the. Graph. Pete Gemmell æ. December 14, Abstract

1. Consider the 62-element set X consisting of the twenty-six letters (case sensitive) of the English

Graph Algorithms (part 3 of CSC 282),

Problem 1. Which of the following is true of functions =100 +log and = + log? Problem 2. Which of the following is true of functions = 2 and =3?

Solutions to Final. Solutions to Final. May 18th CS170 David Wolfe ALWAYS TRUE SOMETIMES TRUE NEVER TRUE

Department of Computer Applications. MCA 312: Design and Analysis of Algorithms. [Part I : Medium Answer Type Questions] UNIT I

22 Elementary Graph Algorithms. There are two standard ways to represent a

Introduction to Algorithms May 14, 2003 Massachusetts Institute of Technology Professors Erik Demaine and Shafi Goldwasser.

CS345 Midterm Examination. Wednesday, May 14, 2003, 9:30 í 11:30AM. Directions. The exam is open book; any written materials may be used.

Student Name and ID Number. MATH 3012 Final Exam, December 11, 2014, WTT

( ) n 3. n 2 ( ) D. Ο

CS 5515 Fall Solution to Test è1. Open booksènotes; calculator allowed

(a) Write code to do this without using any floating-point arithmetic. Efficiency is not a concern here.

1. Let n and m be positive integers with n m. a. Write the inclusion/exclusion formula for the number S(n, m) of surjections from {1, 2,...

The ray tracing software package implements an object-oriented approach to

Boundary layer quadrilateral. Boundary layer

4/8/11. Single-Source Shortest Path. Shortest Paths. Shortest Paths. Chapter 24

Lecture 13. Reading: Weiss, Ch. 9, Ch 8 CSE 100, UCSD: LEC 13. Page 1 of 29

CS161 - Final Exam Computer Science Department, Stanford University August 16, 2008

logn D. Θ C. Θ n 2 ( ) ( ) f n B. nlogn Ο n2 n 2 D. Ο & % ( C. Θ # ( D. Θ n ( ) Ω f ( n)

Solving problems on graph algorithms

skim it quickly and read any sections that appear both relevant and accessible.

Chapter 9 Graph Algorithms

( D. Θ n. ( ) f n ( ) D. Ο%

CS521 \ Notes for the Final Exam

Question Points Score TOTAL 55 TOTAL (Calibrated) 50

Minimum Spanning Tree

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

n 2 ( ) ( ) + n is in Θ n logn

COMPSCI 311: Introduction to Algorithms First Midterm Exam, October 3, 2018

Your favorite blog : (popularly known as VIJAY JOTANI S BLOG..now in facebook.join ON FB VIJAY

CS 161 Fall 2015 Final Exam

Math Summer 2012

UC Berkeley CS 170: Efficient Algorithms and Intractable Problems Handout 7 Lecturer: David Wagner February 13, Notes 7 for CS 170

The Shortest Path Problem. The Shortest Path Problem. Mathematical Model. Integer Programming Formulation

NANYANG TECHNOLOGICAL UNIVERSITY SEMESTER II EXAMINATION MH 1301 DISCRETE MATHEMATICS TIME ALLOWED: 2 HOURS

RYERSON UNIVERSITY DEPARTMENT OF COMPUTER SCIENCE CPS 616 FINAL EXAM WINTER 2018

Multiple Choice. Write your answer to the LEFT of each problem. 3 points each

where C is traversed in the clockwise direction, r 5 èuè =h, sin u; cos ui; u ë0; çè; è6è where C is traversed in the counterclockwise direction èhow

1 Shortest Paths. 1.1 Breadth First Search (BFS) CS 124 Section #3 Shortest Paths and MSTs 2/13/2018

CMSC351 - Fall 2014, Final Exam

Dijkstra s algorithm for shortest paths when no edges have negative weight.

Worksheet for the Final Exam - Part I. Graphs

Spanning Trees. Lecture 20 CS2110 Spring 2015

( ) 1 B. 1. Suppose f x

TA: Jade Cheng ICS 241 Recitation Lecture Notes #12 November 13, 2009

CME 305: Discrete Mathematics and Algorithms Instructor: Reza Zadeh HW#3 Due at the beginning of class Thursday 02/26/15

CS261: Problem Set #2

Homework 5: Graphs, Minimum Spanning Trees, and Dijkstra Shortest-Path

2. True or false: even though BFS and DFS have the same space complexity, they do not always have the same worst case asymptotic time complexity.

Theorem 2.9: nearest addition algorithm

18 Spanning Tree Algorithms

Ma/CS 6a Class 27: Shortest Paths

APPM 4120/5120 Exam #2 Practice Solutions Spring 2015

University of New Mexico Department of Computer Science. Final Examination. CS 362 Data Structures and Algorithms Spring, 2006

n 2 C. Θ n ( ) Ο f ( n) B. n 2 Ω( n logn)

ECE250: Algorithms and Data Structures Final Review Course

( ). Which of ( ) ( ) " #& ( ) " # g( n) ( ) " # f ( n) Test 1

1 Format. 2 Topics Covered. 2.1 Minimal Spanning Trees. 2.2 Union Find. 2.3 Greedy. CS 124 Quiz 2 Review 3/25/18

Department of Computer Science and Engineering Analysis and Design of Algorithm (CS-4004) Subject Notes

Chapter 9 Graph Algorithms

term Oè1=n k è. This time bound is a substantial improvement for sparse graphs. Still in the dense case this algorithm is slower than the original GW

CSE 100: B+ TREE, 2-3 TREE, NP- COMPLETNESS

Unit 8: Coping with NP-Completeness. Complexity classes Reducibility and NP-completeness proofs Coping with NP-complete problems. Y.-W.

One motivation for developing axiomatic systems is to determine precisely which properties

CMPSCI 311: Introduction to Algorithms Practice Final Exam

CMSC Theory of Algorithms Second Midterm

53 M 0 j èm 2 i è ;1 M 0 j èm 2 i è ;1 èm 2 i è ;0 èm 2 i è ;0 (a) (b) M 0 i M 0 i (c) (d) Figure 6.1: Invalid boundary layer elements due to invisibi

REDUCTION CUT INVERTED SUM

Unit 3 (Part-I): Greedy Algorithms

Chapter 23. Minimum Spanning Trees

Test 1 Last 4 Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. 2 points each t 1

D. Θ nlogn ( ) D. Ο. ). Which of the following is not necessarily true? . Which of the following cannot be shown as an improvement? D.

22 Elementary Graph Algorithms. There are two standard ways to represent a

n 2 ( ) ( ) Ο f ( n) ( ) Ω B. n logn Ο

Practice Exam #3, Math 100, Professor Wilson. MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Minimum spanning trees

NP-Completeness. Algorithms

Sample Solutions to Homework #4

The exam is open book; any written materials may be used, as well as on-line or

Spanning Trees, greedy algorithms. Lecture 20 CS2110 Fall 2018

10/31/18. About A6, Prelim 2. Spanning Trees, greedy algorithms. Facts about trees. Undirected trees

CMSC351 - Fall 2014, Homework #6

k 1234 k-nodes k 12 k 234 k 4 k 1 k 2 k 3 u 3 u 4 u 1 u 2 u-nodes

1 Shortest Paths. 1.1 Breadth First Search (BFS) CS 124 Section #3 Shortest Paths and MSTs 2/13/2018

Shortest path problems

Student Name and ID Number. MATH 3012, Quiz 3, April 16, 2018, WTT

In this lecture, we ll look at applications of duality to three problems:

Computing the Median with Uncertainty. Jennifer Widom í. be pinned-down as desired regardless of the results of the. queries.

NP and computational intractability. Kleinberg and Tardos, chapter 8

Transcription:

1 Exam 2 Computer Engineering 251 Santa Clara University Thursday, 23 April 1998 NAME èprintedè NAME èsignedè Login Day of Lab Session Please show all your work and circle your answers. Your grade will be based on the the work shown. Question 1 è10 pointsè Question 2 è10 pointsè Question 3 è10 pointsè Question 4 è10 pointsè Question 5 è10 pointsè Question 6 è10 pointsè Question 7 è20 pointsè Question 8 è20 pointsè TOTAL

Name: 2 Useful Formulas Pn i=1 i = nèn+1è 2 Pn i=1 xi = xn+1,1 x,1 P Pn 1 =lnn + Oè1è 1 i=1 i i=0 = ixi x è1,xè 2 e x =1+x + x2 + x 3 2! 3! + ::: lim n!1è1 + x n èn = e x n! = p 2çnè n e èn è1+æè 1 n èè n! =oènn è n! =!è2 n è lgèn!è = æèn lg nè ç çn enk ç è èk çn kç = n! è n k!èn,kè! k èk ç EëXë = Px xp rëx = xë VarëXë =EëèX, EëXëè 2 ë = EëX 2 ë, E 2 ëxë k íput gatesèformulas hereí

Name: 3 1. è10 pointsè 5 short answers èmorningè or 10 TèF èeveningè èaè Inaæow network, the æow on an edge is always larger than the capacity of the edge. èbè The longest simple path in an undirected graph has at most V, 1 edges. ècè èdè èeè Greedy algorithms always ænd the optimal solution to a problem. Every logical gate has fan-in 2 èthat is, has exactly 2 inputsè. Prim's Algorithm and Kruskal's Algorithm solve the same problem. èfè How many diæerent minimal spanning trees are there on a triangle with edge weights 1 èthat is, the graph G =èf1; 2; 3g; fè1; 2è; è1; 3è; è2; 3èg and wè1; 3è = wè1; 3è = wè2; 3è = 1è? ègè What is the most number of edges possible in a matching on a graph G =èv; Eè, where the number of vertices is even? èhè In a æow network, what is the capacity of a path, p, if the capacity of each edge èu; vè iscèu; vè? èiè How can the number of strongly connected components in a graph change if a new edge is added? èjè If an undirected graph has E edges and V vertics, how many edges does a spanning tree of the graph have? 2. è10 pointsè Huæman encoding èaè Given the following character set and the frequency each letter occurs, construct a Huæman code for the character set: a b c d e f Frequency èin thousandsè 45 13 12 16 9 5 èbè Given the following character set and the frequency each letter occurs, construct a Huæman code for the character set: a b c d e f Frequency èin thousandsè 5 11 1 4 9 1

Name: 4 3. è10 pointsè Give algorithm and example èaè èmorningè i. Write Dijkstra's Algorithm. ii. Give a simple example of a directed graph with negative-weight edges for which Dijkstra's Algorithm produces incorrect answers. èbè èeveningè i. Write Kruskal's Algorithm ii. Suppose that all the edge weights in the graph are integers in the range from 1 to jv j. How fast can you make Kruskal's Algorithm run? 4. è10 pointsè Analyze graph algorithms èaè Analyze the following algorithm: G is a directed graph with weight function w and s is a vertex of G. BELLMAN-FORDèG,w,sè 1 INITIALIZE-SINGLE-SOURCEèG,sè 2 for i é- 1 to VëGë - 1 3 do for each edge èu,vè in EëGë 4 do RELAXèu,v,wè 5 for each edge èu,vè in EëGë 6 do if dëvë é dëuë + wèu,vè 7 then return FALSE 8 return TRUE INITIALIZE-SINGLE-SOURCEèG,sè 1 for each vertex v in VëGë 2 do dëvë é- infinity 3 pëvë é- NIL 4 dësë é- 0 RELAXèu,v,wè 1 if dëvë é dëuë + wèu,vè 2 then dëvë é- dëuë + wèu,vè 3 pëvë é- u èbè Analyze the following algorithm. You may assume that all æows are integer-valued èthat is, fëu,vë is always an integerè and jf æjis the value of the maximal æow.

Name: 5 G is a directed graph with s and t vertices in G. ènote: Due to typesetting FORD-FULKERSONèG,s,tè 1 for each edge èu,vè in EëGë 2 do fëu,vë é- 0 3 fëv,uë é- 0 4 while there exists a path p from s to t in the residual network Gf 5 do cfèpè é- minícfèu,vè : èu,vè is in pí 6 for each edge èu,vè in p 7 do fëu,vë é- fëu,vë + cfèpè 8 fëv,uë é- - fëu,vë 5. è10 pointsè Simple circuit question èaè i. Draw a circuit that takes 3 bit inputs x; y; z and return 1 if their sum is odd and 0 if their sum is even. ii. Draw a circuit that takes 4 bit inputs x; y; z; w and return 1 if their sum is odd and 0 if their sum is even. èbè i. Draw a circuit that takes 3 bit inputs x; y; z. The circuit should have 2 outputs: c and s. The output c should be 1 iæ at least 2 of the inputs are 1. The output s should be 1 if the sum of the inputs is odd and 0 if sum of the inputs is even. ii. Use your circuit from above to design a circuit that will add two 4- digit binary numbers. èyou may represent the circuit from above as a ëblack box" instead of redrawing it for this part of the question.è 6. è10 pointsè èaè Draw an example of æow network with a æow that is not maximal. Label the edges of your graph with the æow and capacity of the edge. Also indicate an augmenting path for your æow. èbè Show that for any graph G =èv; Eè, there exists a minimal spanning tree that contains the minimal weight edge. 7. è20 pointsè Solve recurrences using generating functions èaè Solve the following recurrence: T n+2 =2T n+1, T n for n ç 0, T 0 =0;T 1 =1 èhint: let T èxè = Pn T n x n, solve for Tèxè, and use formulas about sums to decide the coeæentsè.

Name: 6 èbè Solve the following recurrence: T n = nx k=0 T k for n ç 1, T 0 =1 èhint: let T èxè = Pn T n x n, solve for Tèxè, and use formulas about sums to decide the coeæentsè. 8. è20 pointsè Design an algorithm... èaè è20 pointsè Design a greedy algorithm for storing web pages in memory. The total size of memory is M. As each page arrives, you should place it memory if space is available. If space is not available, you should remove another page èor pagesè from memory and insert your page. The pages will be speciæed by their size only. For example, if M = 10 and the sequence of page sizes is 1; 5; 8; 1, you would insert the ærst 2 pages, then need to remove at least the second page to insert the third page. After that you, you can insert the fourth page. Please specify the data structures you used and give an analysis of the program. èbè è20 pointsè Arbitrage is the use of discrepencies in currency exchange rates to transform one unit of currency into more than one unit of the same currency. For example, suppose that 1 US dollar buys 0.7 British pounds, 1 British pound buys 9.5 French francs, and 1 French franc buys 0.16 dollars. By converting currencies, a trader can start with 1 US dollar and end up with 1 æ 0:7 æ 9:5 æ 0:16=1:064 dollars, and then returning a proæt of 6.4è. Suppose that we are given n currencies c 1 ;c 2 ;:::;c n and an n æ n table R of exchange rates such that one unit of c i buys Rëi; jë units of currency c j. Give an eæcient algorithm for deciding whether or not there exists a sequence of currencies that will yield a proæt. Specify any data structures you use and give ananalysis of the program.