CS381_PSO_HW_Spring_2024

.pdf

School

Purdue University *

*We aren’t endorsed by this school

Course

381

Subject

Computer Science

Date

Feb 20, 2024

Type

pdf

Pages

5

Uploaded by BailiffKangaroo6144

CS 381-Spring 2024 Homework 2 Due Date: Feb 13 at 11:59PM on Gradescope. Instructors: Jeremiah Blocki and Simina Branzei Name: Purdue ID: Learning Objectives The homework is relevant to the following learning objectives: LO 1.1 Students are able to devise randomized algorithms (including but not limited to divide-and-conquer style of algorithms) and analyze their behavior. LO 2.2 Students are able to extract the recurrence relationship from divide-and-conquer algorithms. LO 3.1 Students are able to use induction/invariant to prove that a divide-and-conquer algorithm is correct. Understanding the role of randomization in the design and analysis of algorithms. Homework Guideline Reminders Assignments must be typed. Submit one pdf file to Gradescope by 11:59PM, or else late penalties will apply. The pdf file can include hand-drawn images of figures. Each question needs to start with the resources and collaborator (RC) statement. You will not be penalized for using resources or having collaborators if your answers are expressed in your own words. If you consulted no resources outside of course material or had no collaborators, you must state so. A question without a complete RC statement will not be graded. 1
Question 0 (5 points) Write the names of all your study group members, both here and in the file online: https:// docs.google.com/document/d/1nx5sdsN_k1Kpf74-xGO3UFuQj5gvQQ4iE-HMksYJo2c/edit . This should include your own name. Question 1 (25 points) 3-Coloring is a yes/no question, but we can phrase it as an optimization problem as follows. Suppose we are given a graph G = ( V, E ), and we want to color each node with one of three colors (red, green or blue) such that for each edge { u, v } ∈ E the endpoints u and v have a different color. We say that an edge ( u, v ) is satisfied if the colors c ( u ) and c ( v ) assigned to u and v respectively are different i.e., c ( u ) ̸ = c ( v ). Even if we aren’t necessarily able to give different colors to every pair of adjacent edges we may still want to find a 3-Coloring that satisfies as many edges as we can. 1. Suppose that we partition V into two parts V 1 and V 2 . Let E 1 (resp. E 2 ) denote the set of edges e = { u, v } between two nodes in V 1 (resp. V 2 ) and let E 3 denote the set of crossing edges with one endpoint in V 1 and one endpoint in V 2 . See the footnote 1 below for a formal definition of E 1 , E 2 and E 3 . Suppose that Alice finds a coloring c Alice : V 1 → { R, G, B } of the nodes in V 1 which satisfies at least z 1 edges from E 1 and that Bob finds a coloring c Bob : V 2 → { R, G, B } of the nodes in V 2 which satisfies at least z 2 edges. Show that there is a coloring c : V → { R, B, G } of the entire graph which satisfies at least z 1 + z 2 + 2 3 | E 3 | edges in E . ( Hint: It may help to use a probabilistic argument involving linearity of expectation). 2. Give a deterministic divide and conquer style algorithm which outputs a coloring that satisfies at least 2 | E | / 3 edges. Analyze the running time of your algorithm and prove that your algorithm satisfies at least 2 | E | / 3 of the edges in the graph. Collaborators: Resources: Solution: 1 Formally, E 1 = {{ u, v } E : u, v V 1 } and E 2 = {{ u, v } E : u, v V 2 } and E 3 = {{ u, v } ∈ E : ( u V 1 v V 2 ) ( u V 2 v V 1 ) } . 2
Question 2 (25 points) Consider the following gambling strategy to use in a casino: on the first play, stake $ 1; on the second play $ 2; on the third play $ 4; on the k -th play $ 2 k 1 . Stop (i.e. leave the casino) when winning for the first time. Assume each play to be fair: that is, you win or lose with probability 1 / 2. (Note: Betting $ y dollars means that if you lose the bet, you pay the casino $ y dollars, while if you win, you receive $ y dollars.) (Part a. 13 points) Show that, if you follow this strategy, you will eventually leave the casino $ 1 richer with probability 1. Justify your answers. (Part b. 12 points) Let X be the random variable that measures your maximum loss before winning (that is, the amount of money you have lost before the play on which you win). What is E [ X ]? What does this tell about your ability to implement the strategy? Justify your answers. Collaborators: Resources: Solution: 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help