CSE21 - Math for Algorithm and Systems...

23
Sample Final Questions for RRR - Complexity Zoo and Counting F1. Find the error in this false statement and correct it: Finding the chromatic number of a graph is NP-complete.F2. Find the error in this false statement and correct it: Solving the Traveling Salesman Problem NP-complete.F3. Is this problem “Is the number N=561 composite?” in NP? F4. Count the number of proper 3-colorings of the graph G : G v 3 v 2 v 1 v 4 F5. Count the number of proper colorings of the graph G above that uses at most one color. Count the number of proper colorings of the graph G above that uses at most two colors. Count the number of proper colorings of the graph G above that uses at most four colors. Rubalcaba ([email protected] ) Sample Final Questions 1 / 15

Transcript of CSE21 - Math for Algorithm and Systems...

Page 1: CSE21 - Math for Algorithm and Systems Analysisvlsicad.ucsd.edu/courses/cse21-s14/slides/Rubalcaba... · Rubalcaba (rrrubalcaba@eng.ucsd.edu) SampleFinalQuestions 20/15. SampleFinalQuestionsforRRR-Howacomputermight

Sample Final Questions for RRR - Complexity Zoo and

Counting

F1. Find the error in this false statement and correct it:“Finding the chromatic number of a graph is NP-complete.”

F2. Find the error in this false statement and correct it:“Solving the Traveling Salesman Problem NP-complete.”

F3. Is this problem “Is the number N=561 composite?” in NP?

F4. Count the number of proper 3-colorings of the graph G :

G

v3v

2v

1v

4

F5. Count the number of proper colorings of the graph G above that usesat most one color. Count the number of proper colorings of the graphG above that uses at most two colors. Count the number of propercolorings of the graph G above that uses at most four colors.

Rubalcaba ([email protected]) Sample Final Questions 1 / 15

Page 2: CSE21 - Math for Algorithm and Systems Analysisvlsicad.ucsd.edu/courses/cse21-s14/slides/Rubalcaba... · Rubalcaba (rrrubalcaba@eng.ucsd.edu) SampleFinalQuestions 20/15. SampleFinalQuestionsforRRR-Howacomputermight

Sample Final Questions for RRR - Greedy Colorings

F6. Given this set of colors t1, 2, 3, 4, 5, 6u greedily color the vertices ofthe graph using this ordering v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12of the vertices.

G

v

2v

3v

4v

5v

6v

7v

8v

9v

10v

11v

12v

1

F7. Given this set of colors t1, 2, 3, 4, 5, 6u greedily color the vertices ofthe above graph using this orderingv1, v2, v3, v5, v7, v9, v11, v4, v6, v8, v10, v12 of the vertices.

F8. Explain the difference between greedy coloring and the chromaticnumber.

Rubalcaba ([email protected]) Sample Final Questions 2 / 15

Page 3: CSE21 - Math for Algorithm and Systems Analysisvlsicad.ucsd.edu/courses/cse21-s14/slides/Rubalcaba... · Rubalcaba (rrrubalcaba@eng.ucsd.edu) SampleFinalQuestions 20/15. SampleFinalQuestionsforRRR-Howacomputermight

Sample Final Questions for RRR - Minimum Proper

Colorings

For F9 - F13 properly color the vertices of the graph using the minimumnumber of colors.

F9. The complete multipartite graph K2,3,3,7.

F10. The Petersen graph

F11. The Grotzsch graph

F12. A random tree on 10 vertices.

F13. The graph G in question F6

Rubalcaba ([email protected]) Sample Final Questions 3 / 15

Page 4: CSE21 - Math for Algorithm and Systems Analysisvlsicad.ucsd.edu/courses/cse21-s14/slides/Rubalcaba... · Rubalcaba (rrrubalcaba@eng.ucsd.edu) SampleFinalQuestions 20/15. SampleFinalQuestionsforRRR-Howacomputermight

Sample Final Questions for RRR - Graph Isomorphisms

F14. Are these two graphs isomorphic?Hv

3v

2v

10v

4v

5v6v

7v

8v

9v

1u 2u

3u

4u

5u

6u7u

8u

9u

10u

G 1

F15. In two line notation, list all isomorphisms from G to H

u

v1v 3v

6v5v4v

3u

4u 5u 6

2 HG

1u 2u

Rubalcaba ([email protected]) Sample Final Questions 4 / 15

Page 5: CSE21 - Math for Algorithm and Systems Analysisvlsicad.ucsd.edu/courses/cse21-s14/slides/Rubalcaba... · Rubalcaba (rrrubalcaba@eng.ucsd.edu) SampleFinalQuestions 20/15. SampleFinalQuestionsforRRR-Howacomputermight

Sample Final Questions for RRR - Graph Isomorphisms

F16. Are these two graphs isomorphic?Hv

3v

2v

10v

4v

5v6v

7v

8v

9v

10u

1u

4u7u

3u

2u

8u

9u

5u 6u

G 1

F17. Explain why the YES / NO question is in NP:“Are the two graphs G and H isomorphic?”

F18. Verify that

ˆ

v1 v2 v3 v4 v5 v6 v7 v8 v9 v10u1 u2 u3 u4 u5 v6 u7 u8 u9 u10

˙

is an

isomorphism between the two graphs G and H in F16.

Rubalcaba ([email protected]) Sample Final Questions 5 / 15

Page 6: CSE21 - Math for Algorithm and Systems Analysisvlsicad.ucsd.edu/courses/cse21-s14/slides/Rubalcaba... · Rubalcaba (rrrubalcaba@eng.ucsd.edu) SampleFinalQuestions 20/15. SampleFinalQuestionsforRRR-Howacomputermight

Sample Final Questions for RRR - Graph modeling question

F19. Given these five websites and links between them, how would youmodel this as a graph or a directed graph?

vlsicad.ucsd.edu/courses/cse−s14/

webwork.cse.ucsd.edu/webwork2/CSE21_Spring2014 https://piazza.com/ucsd/spring2014/cse21/home

vlsicad.ucsd.edu/courses/cse−s14/

Links to websites:

webwork.cse.ucsd.edu/webwork2/CSE21_Spring2014

https://piazza.com/ucsd/spring2014/cse21/home

Links to websites:

www.soundcloud.com/ProfessorShadow

www.instagram.com/ProfessorShadow

www.soundcloud.com/ProfessorShadow

Links to websites:

www.soundcloud.com/ProfessorShadow

Links to websites:

webwork.cse.ucsd.edu/webwork2/CSE21_Spring2014

Links to websites:

Rubalcaba ([email protected]) Sample Final Questions 6 / 15

Page 7: CSE21 - Math for Algorithm and Systems Analysisvlsicad.ucsd.edu/courses/cse21-s14/slides/Rubalcaba... · Rubalcaba (rrrubalcaba@eng.ucsd.edu) SampleFinalQuestions 20/15. SampleFinalQuestionsforRRR-Howacomputermight

Sample Final Questions for RRR - Minimum Spanning

Trees

F20. Using the greedy algorithm, find the minimum weight spanning tree.F21. What is the total weight of the minimum spanning tree?

189

2

18

1 11

10

12

5

8

13

17

A

72

6

B C D

E F G

H I J

Z4

3

2321

16

1415

Rubalcaba ([email protected]) Sample Final Questions 7 / 15

Page 8: CSE21 - Math for Algorithm and Systems Analysisvlsicad.ucsd.edu/courses/cse21-s14/slides/Rubalcaba... · Rubalcaba (rrrubalcaba@eng.ucsd.edu) SampleFinalQuestions 20/15. SampleFinalQuestionsforRRR-Howacomputermight

Sample Final Questions for RRR - Traveling Salesman

Problem

F22. Using the sorted edges method, find the length of the tour goingthrough all six cities.

15

CB

A

EF

D

1

3

2

4

5

6

7

8

9

10

11

1213

14

Rubalcaba ([email protected]) Sample Final Questions 8 / 15

Page 9: CSE21 - Math for Algorithm and Systems Analysisvlsicad.ucsd.edu/courses/cse21-s14/slides/Rubalcaba... · Rubalcaba (rrrubalcaba@eng.ucsd.edu) SampleFinalQuestions 20/15. SampleFinalQuestionsforRRR-Howacomputermight

Sample Final Questions for RRR - Traveling Salesman

Problem

F23. Using the nearest neighbor method, find the length of the tour goingthrough all six cities, starting and ending at A.

15

CB

A

EF

D

1

3

2

4

5

6

7

8

9

10

11

1213

14

Rubalcaba ([email protected]) Sample Final Questions 9 / 15

Page 10: CSE21 - Math for Algorithm and Systems Analysisvlsicad.ucsd.edu/courses/cse21-s14/slides/Rubalcaba... · Rubalcaba (rrrubalcaba@eng.ucsd.edu) SampleFinalQuestions 20/15. SampleFinalQuestionsforRRR-Howacomputermight

Sample Final Questions for RRR - Permutations

F24. rp1, 2, 3, 4q ˝ p1, 2qp3, 5qs´1

F25. The cipher is given below in two line notation:ˆ

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

D E F G H I J K L M N O P Q R S T U V W X Y Z A B C

˙

Decrypt this message that was encrypted with the above cipher:S U R J U D P P L Q J L Q W K H E D V H P H Q W V W L Q N V

F26. What is the probability that a random permutation on five letters is aderangement?

Rubalcaba ([email protected]) Sample Final Questions 10 / 15

Page 11: CSE21 - Math for Algorithm and Systems Analysisvlsicad.ucsd.edu/courses/cse21-s14/slides/Rubalcaba... · Rubalcaba (rrrubalcaba@eng.ucsd.edu) SampleFinalQuestions 20/15. SampleFinalQuestionsforRRR-Howacomputermight

Sample Final Questions for RRR - Random Graphs

For F27–F29: Let B be a random bipartite graph with independent sets ofsizes |X | “ 3 and |Y | “ 5. Each edge px , yq of B has probability 1

5 .

F27. Draw an example of a random bipartite graph with independent setsof sizes 3 and 5.

F28. What is the maximum number of edges in B?

F29. What is the probability that B has 5 edges?

F30. What is the expected number of edges of B?

Rubalcaba ([email protected]) Sample Final Questions 11 / 15

Page 12: CSE21 - Math for Algorithm and Systems Analysisvlsicad.ucsd.edu/courses/cse21-s14/slides/Rubalcaba... · Rubalcaba (rrrubalcaba@eng.ucsd.edu) SampleFinalQuestions 20/15. SampleFinalQuestionsforRRR-Howacomputermight

Sample Final Questions for RRR - Basic Counting

F31. How many solutions using positive integers are there to the equationx1 ` x2 ` x3 ` x4 ` x5 “ 15?

F32. How many possible surjections are there from t1, 2, 3, 4u ÞÑ tA,Bu?

F33. How many possible injections are there from t1, 2, 3, 4u ÞÑ tA,Bu?

F34. How many possible injections are there from tA,Bu ÞÑ t1, 2, 3, 4u?

F35. N “ 210 “ 2 ˆ 3 ˆ 5 ˆ 7. How many ways can you write this as aproduct of non-negative integers? (Hint: The number 30 has five ways:

2 ˆ 3 ˆ 5 “ 2 ˆ 15 “ 6 ˆ 5 “ 3 ˆ 10 “ 30)

Rubalcaba ([email protected]) Sample Final Questions 12 / 15

Page 13: CSE21 - Math for Algorithm and Systems Analysisvlsicad.ucsd.edu/courses/cse21-s14/slides/Rubalcaba... · Rubalcaba (rrrubalcaba@eng.ucsd.edu) SampleFinalQuestions 20/15. SampleFinalQuestionsforRRR-Howacomputermight

Sample Final Questions for RRR - Conditional Probability

and Independence

F36. PpAq “ 0.3,PpA Y Bq “ 0.7, and PpBqc “ 0.6. Are A and B

independent events?

F37. Among 60-year-old college professors, 10% are smokers and 90% arenonsmokers. The probability of a non-smoker dying in the next year is0.005 and the probability of a smoker dying is 0.05. Given that one60-year-old professor dies in the next year, what is the probability thatthe professor is a smoker?

F38. At a hospital’s emergency room, patients are classified and 20% arecritical, 30% are serious and 50% are stable. Of the critical patients,30% die; of the serious patients, 10% die; and of the stable patients,1% die.

§ (a) What is the probability that a patient who dies was classified ascritical?

§ (b) What is the probability that a critical patient dies?

Rubalcaba ([email protected]) Sample Final Questions 13 / 15

Page 14: CSE21 - Math for Algorithm and Systems Analysisvlsicad.ucsd.edu/courses/cse21-s14/slides/Rubalcaba... · Rubalcaba (rrrubalcaba@eng.ucsd.edu) SampleFinalQuestions 20/15. SampleFinalQuestionsforRRR-Howacomputermight

Sample Final Questions for RRR - Conditional Probability

and Independence

F40. In Madison County, Alabama, a sample of 100 cases from 1960 areinvestigated, and the 100 defendants are interviewed as to their trueinnocence or guilt.

B1 Actually guilty B2 Actually innocent totals

A1 Jury finds guilty 35 45 80

A2 Jury finds not guilty 5 15 20

totals 40 60 100

§ (a) Assuming they answer honestly, what is the probability that adefendant who was actually innocent was found guilty by a jury?

§ (b) What is the probability that a defendant that was found guilty by ajury was actually innocent?

§ (c) Are the events A1 and B2 independent?

Rubalcaba ([email protected]) Sample Final Questions 14 / 15

Page 15: CSE21 - Math for Algorithm and Systems Analysisvlsicad.ucsd.edu/courses/cse21-s14/slides/Rubalcaba... · Rubalcaba (rrrubalcaba@eng.ucsd.edu) SampleFinalQuestions 20/15. SampleFinalQuestionsforRRR-Howacomputermight

Sample Final Questions for RRR - Recursion, Big-O

F41. The determinant of a matrix can be calculated by expansion alongminors. The determinant detpMq of the n ˆ n square matrix M canbe recursively calculated as:detpMq “ m11 ¨ detpM11q ` ¨ ¨ ¨ ` p´1q1`j ¨ m1j ¨ detpM1jq ` ¨ ¨ ¨ whereM1j is the submatrix formed by eliminating the first row and jth

column of M. Give an expression for Rpnq, the asymptotic number ofmultiplications and additions used to calculate the determinant of ann ˆ n matrix using the above recursion.

F42.`

N2

˘

is Op?q

F43. !N (which counts the number of derangements on N letters) is Op?q

F44. Finding thee shortest tour through N cities (for the travelingsalesman problem) is Op?q

Rubalcaba ([email protected]) Sample Final Questions 15 / 15

Page 16: CSE21 - Math for Algorithm and Systems Analysisvlsicad.ucsd.edu/courses/cse21-s14/slides/Rubalcaba... · Rubalcaba (rrrubalcaba@eng.ucsd.edu) SampleFinalQuestions 20/15. SampleFinalQuestionsforRRR-Howacomputermight

Sample Final Questions for RRR - Modeling and solving

real world problems

F45. Roadtrip! You just joined a band and you are on a tour of thefollowing six cities. Note that not all cities are connected by roads.Find the absolute shortest tour while visiting each city exactly once,starting and returning to San Diego.

6

9

2

3

8

5

7

San Diego

Los Angeles San Francisco

Phoenix

Fresno

Yuma

1

4

Rubalcaba ([email protected]) Sample Final Questions 16 / 15

Page 17: CSE21 - Math for Algorithm and Systems Analysisvlsicad.ucsd.edu/courses/cse21-s14/slides/Rubalcaba... · Rubalcaba (rrrubalcaba@eng.ucsd.edu) SampleFinalQuestions 20/15. SampleFinalQuestionsforRRR-Howacomputermight

Sample Final Questions for RRR - Modeling and solving

real world problems

F46. Street sweeping in South Park. If the street sweeper starts at thecorner of Date and 28th Street, is it possible for the street sweeper toclean each side of the street and return to 28th and Date, withoutdiving down any side of the street more than once?

Rubalcaba ([email protected]) Sample Final Questions 17 / 15

Page 18: CSE21 - Math for Algorithm and Systems Analysisvlsicad.ucsd.edu/courses/cse21-s14/slides/Rubalcaba... · Rubalcaba (rrrubalcaba@eng.ucsd.edu) SampleFinalQuestions 20/15. SampleFinalQuestionsforRRR-Howacomputermight

Sample Final Questions for RRR - Modeling and solving

real world problems

F47. Mail Delivery in South Park. If the mail carrier starts at the corner ofDate and 28th Street, is it possible for the mail carrier to deliver mailto each house and business and return to 28th and Date, withoutwalking down a any sidewalk more than once?

Rubalcaba ([email protected]) Sample Final Questions 18 / 15

Page 19: CSE21 - Math for Algorithm and Systems Analysisvlsicad.ucsd.edu/courses/cse21-s14/slides/Rubalcaba... · Rubalcaba (rrrubalcaba@eng.ucsd.edu) SampleFinalQuestions 20/15. SampleFinalQuestionsforRRR-Howacomputermight

Sample Final Questions for RRR - Modeling and solving

real world problems

F48. Map coloring. Color the map of the following countries so that notwo countries that share a border get colored with the same color.Model this as a graph problem, solve the graph problem, then solvethe original map coloring question.

Rubalcaba ([email protected]) Sample Final Questions 19 / 15

Page 20: CSE21 - Math for Algorithm and Systems Analysisvlsicad.ucsd.edu/courses/cse21-s14/slides/Rubalcaba... · Rubalcaba (rrrubalcaba@eng.ucsd.edu) SampleFinalQuestions 20/15. SampleFinalQuestionsforRRR-Howacomputermight

Sample Final Questions for RRR - Modeling and solving

real world problems

F49. High speed network. In a new housing development the internetservice provider needs to provide high speed access to each hometA,B ,C ,Du using the fewest underground cables. This networkneeds to be connected. Find the cheapest high speed network thatconnects all of the homes tA,B ,C ,Du, using the fewest undergroundcables given the following underground cable costs:

A B C D

A 70 10 3

B 70 7 5

C 10 7 2

D 3 5 2

Rubalcaba ([email protected]) Sample Final Questions 20 / 15

Page 21: CSE21 - Math for Algorithm and Systems Analysisvlsicad.ucsd.edu/courses/cse21-s14/slides/Rubalcaba... · Rubalcaba (rrrubalcaba@eng.ucsd.edu) SampleFinalQuestions 20/15. SampleFinalQuestionsforRRR-Howacomputermight

Sample Final Questions for RRR - How a computer might

see a graph

F50. Find a way of communicating this graph to a computer, which cannot see images, only lists or arrays (i.e. matrices).

Gv1v 3v

6v5v4v

2

Rubalcaba ([email protected]) Sample Final Questions 21 / 15

Page 22: CSE21 - Math for Algorithm and Systems Analysisvlsicad.ucsd.edu/courses/cse21-s14/slides/Rubalcaba... · Rubalcaba (rrrubalcaba@eng.ucsd.edu) SampleFinalQuestions 20/15. SampleFinalQuestionsforRRR-Howacomputermight

Sample Final Questions for RRR - Graph Modeling

Problem

F51. You are in a band on tour, with shows at: San Diego, CA, Topeka,KS, Washington D.C., Seattle, WA and Auburn, AL. Using the milagebetween the cities, model this as a graph problem where you need tovisit each city exactly once, starting and returning to your home inAuburn, AL.

San Diego Auburn Seattle Washington D.C. TopekaSan Diego 0 2059 1255 2614 1492Auburn 2059 0 2631 748 860Seattle 1255 2631 0 2764 1818

Washington D.C. 2614 748 2764 0 1117Topeka 1492 860 1818 1117 0

Rubalcaba ([email protected]) Sample Final Questions 22 / 15

Page 23: CSE21 - Math for Algorithm and Systems Analysisvlsicad.ucsd.edu/courses/cse21-s14/slides/Rubalcaba... · Rubalcaba (rrrubalcaba@eng.ucsd.edu) SampleFinalQuestions 20/15. SampleFinalQuestionsforRRR-Howacomputermight

Sample Final Questions for RRR - Solving the TSP vs

greedy approximations

F52. What is the length of the tour found by using the nearest neighbormethod, starting at Auburn, AL and visiting all four other cities andthen returning to Auburn, AL? (same problem as HW9, number 11a)

F53. What is the length of the tour found by using the sorted edgesmethod, starting at Auburn, AL and visiting all four other cities andthen returning to Auburn, AL? (same problem as HW9, number 11b)

F54. List all tours and calculate the cost for each tour. (Seepiazza post 678)

F55. What is the absolute shortest tour? What is the longest?

F56. Consider the problem: ”Is there a tour through all five cities that usesless than 7000 miles?” Is this problem in NP? Justify your answer.

Rubalcaba ([email protected]) Sample Final Questions 23 / 15