Problem Set 10 Solutions

Similar documents
Foundations of Distributed Systems: Tree Algorithms

Notes for Recitation 3

Problem Set 4 Due: Wednesday, November 12th, 2014

Comp551: Advanced Robotics Lab Lecture 7: Consensus CSE481C wi09 - Robotics Capstone, Lec3: Consensus

Low-Latency Multi-Source Broadcast in Radio Networks

Clock Synchronization

UNIVERSITY of PENNSYLVANIA CIS 391/521: Fundamentals of AI Midterm 1, Spring 2010

Network-Wide Broadcast

From Shared Memory to Message Passing

Checkpoint Questions Due Monday, October 7 at 2:15 PM Remaining Questions Due Friday, October 11 at 2:15 PM

Deterministic Symmetric Rendezvous with Tokens in a Synchronous Torus

ENGI 128 INTRODUCTION TO ENGINEERING SYSTEMS

Search then involves moving from state-to-state in the problem space to find a goal (or to terminate without finding a goal).

CSE 573 Problem Set 1. Answers on 10/17/08

6.042/18.062J Mathematics for Computer Science December 17, 2008 Tom Leighton and Marten van Dijk. Final Exam

DVA325 Formal Languages, Automata and Models of Computation (FABER)

12. 6 jokes are minimal.

Midterm Examination. CSCI 561: Artificial Intelligence

16.410/413 Principles of Autonomy and Decision Making

SOLITAIRE CLOBBER AS AN OPTIMIZATION PROBLEM ON WORDS

TIME- OPTIMAL CONVERGECAST IN SENSOR NETWORKS WITH MULTIPLE CHANNELS

COUNTING AND PROBABILITY

Yale University Department of Computer Science

Your Name and ID. (a) ( 3 points) Breadth First Search is complete even if zero step-costs are allowed.

Lecture 20 November 13, 2014

UMLEmb: UML for Embedded Systems. II. Modeling in SysML. Eurecom

CS188 Spring 2014 Section 3: Games

Mobility Tolerant Broadcast in Mobile Ad Hoc Networks

REU 2006 Discrete Math Lecture 3

Algorithms and Data Structures: Network Flows. 24th & 28th Oct, 2014

Optimal Results in Staged Self-Assembly of Wang Tiles

To be able to determine the quadratic character of an arbitrary number mod p (p an odd prime), we. The first (and most delicate) case concerns 2

Conversion Masters in IT (MIT) AI as Representation and Search. (Representation and Search Strategies) Lecture 002. Sandro Spina

A Memory Efficient Anti-Collision Protocol to Identify Memoryless RFID Tags

Constructions of Coverings of the Integers: Exploring an Erdős Problem

Final exam. Question Points Score. Total: 150

Optimal Clock Synchronization in Networks. Christoph Lenzen Philipp Sommer Roger Wattenhofer

Tight Bounds for Scattered Black Hole Search in a Ring

SF2972: Game theory. Introduction to matching

CONVERGECAST, namely the collection of data from

18.204: CHIP FIRING GAMES

Multiple Communication in Multi-Hop Radio Networks

arxiv: v1 [cs.cc] 21 Jun 2017

arxiv: v1 [math.co] 17 May 2016

Assignment 2. Due: Monday Oct. 15, :59pm

18 Completeness and Compactness of First-Order Tableaux

Introduction to Spring 2009 Artificial Intelligence Final Exam

MITOCW watch?v=2g9osrkjuzm

Lecture 7: The Principle of Deferred Decisions

Constructing K-Connected M-Dominating Sets

Huffman Coding - A Greedy Algorithm. Slides based on Kevin Wayne / Pearson-Addison Wesley

Homework Assignment #1

Advanced Automata Theory 4 Games

From a Ball Game to Incompleteness

Exploring an unknown dangerous graph with a constant number of tokens

Massachusetts Institute of Technology 6.042J/18.062J, Spring 04: Mathematics for Computer Science April 16 Prof. Albert R. Meyer and Dr.

Cryptography. 2. decoding is extremely difficult (for protection against eavesdroppers);

arxiv:cs/ v1 [cs.gt] 12 Mar 2007

Contents. MA 327/ECO 327 Introduction to Game Theory Fall 2017 Notes. 1 Wednesday, August Friday, August Monday, August 28 6

Monitoring Churn in Wireless Networks

Topic 1: defining games and strategies. SF2972: Game theory. Not allowed: Extensive form game: formal definition

Acknowledged Broadcasting and Gossiping in ad hoc radio networks

Which Rectangular Chessboards Have a Bishop s Tour?

Homework Assignment #2

Connected Identifying Codes

Radio Aggregation Scheduling

A Scalable and Adaptive Clock Synchronization Protocol for IEEE Based Multihop Ad Hoc Networks

Game Playing Beyond Minimax. Game Playing Summary So Far. Game Playing Improving Efficiency. Game Playing Minimax using DFS.

Directed Towers of Hanoi

Simple Search Algorithms

CSCI3390-Lecture 8: Undecidability of a special case of the tiling problem

arxiv: v2 [cs.cc] 18 Mar 2013

Grading Delays. We don t have permission to grade you (yet) We re working with tstaff on a solution We ll get grades back to you as soon as we can

Outline for today s lecture Informed Search Optimal informed search: A* (AIMA 3.5.2) Creating good heuristic functions Hill Climbing

Convergence in competitive games

STRATEGY AND COMPLEXITY OF THE GAME OF SQUARES

Data Gathering. Chapter 4. Ad Hoc and Sensor Networks Roger Wattenhofer 4/1

Efficient Symmetry Breaking in Multi-Channel Radio Networks

Last update: March 9, Game playing. CMSC 421, Chapter 6. CMSC 421, Chapter 6 1

: Principles of Automated Reasoning and Decision Making Midterm

Math 127: Equivalence Relations

Tight Bounds for Black Hole Search with Scattered Agents in Synchronous Rings

Selective Families, Superimposed Codes and Broadcasting on Unknown Radio Networks. Andrea E.F. Clementi Angelo Monti Riccardo Silvestri

CMPT 310 Assignment 1

Improved Algorithm for Broadcast Scheduling of Minimal Latency in Wireless Ad Hoc Networks

Section Marks Agents / 8. Search / 10. Games / 13. Logic / 15. Total / 46

Unless stated otherwise, explain your logic and write out complete sentences. No notes, books, calculators, or other electronic devices are permitted.

Multiplayer Pushdown Games. Anil Seth IIT Kanpur

CS 188: Artificial Intelligence Spring 2007

Rumors Across Radio, Wireless, and Telephone

Edge-disjoint tree representation of three tree degree sequences

Randomized broadcast in radio networks with collision detection

On the Time-Complexity of Broadcast in Multi-Hop Radio Networks: An Exponential Gap Between Determinism and Randomization

Gathering an even number of robots in an odd ring without global multiplicity detection

Algorithms. Abstract. We describe a simple construction of a family of permutations with a certain pseudo-random

Game Theory and Algorithms Lecture 19: Nim & Impartial Combinatorial Games

PUZZLES ON GRAPHS: THE TOWERS OF HANOI, THE SPIN-OUT PUZZLE, AND THE COMBINATION PUZZLE

arxiv:cs/ v1 [cs.gt] 7 Sep 2006

Discrete Mathematics and Probability Theory Spring 2018 Ayazifar and Rao Midterm 2 Solutions

MATHEMATICS ON THE CHESSBOARD

Transcription:

Design and Analysis of Algorithms May 8, 2015 Massachusetts Institute of Technology 6.046J/18.410J Profs. Erik Demaine, Srini Devadas, and Nancy Lynch Problem Set 10 Solutions Problem Set 10 Solutions This problem set is due at 11:59pm on Friday, May 8, 2015. Exercise 10-1. Read the lecture slides for Lectures L19 and L20. Problem 10-1. Leader Election in a Synchronous Ring [25 points] Consider a collection of n identical processes arranged in a synchronous ring network. Each process has two sets of ports, one to each of its immediate neighbors, with its ports to its clockwise neighbor named left and its ports to its counterclockwise neighbor named right. Thus, the processes have a common sense of orientation. The goal is for the processes to elect a single leader: exactly one process should eventually output LEADER. (a) [5 points] First suppose that the processes are deterministic, and that they know n (the size of the ring). Either give a correct leader election algorithm for this case, or prove that no such algorithm exists. If you give an algorithm, analyze its time and message complexity. Solution: Impossible. Suppose for contradiction that such an algorithm exists. We can use a standard inductive symmetry argument. Namely, prove by induction on the number r of rounds that, after r rounds, all the processes are in identical states. Since the algorithm must solve the leader election problem, eventually, one process outputs LEADER. But then all processes do the same thing, in the same round. (b) [10 points] Now suppose that the processes are probabilistic (i.e., randomized), and that they know n. We would like an algorithm that (a) never elects more than one leader, and (b) with probability 1, eventually elects a leader. Either give an algorithm satisfying these properties, or prove that none exists. If you give an algorithm, analyze its time and message complexity. Your analysis should relate the complexity to the success probability. Specifically, for any ε, 0 < ε < 1, you should provide bounds on the time and message complexity that hold with probability at least 1 ε. Solution: Here a simple algorithm exists.

2 Problem Set 10 Solutions Lemma, similar to one from class: If n processes choose ids uniformly at random, independently, from {1,..., n 2 }, then with probability at least 1/2, the chosen numbers are all distinct. Algorithm: The algorithm works in a series of phases. In each phase, all processes choose random ids from a sufficiently large space, defined as in the lemma as {1,..., n 2 }. Then they all send their ids around the ring, (say) in the clockwise direction. After exactly n steps, every process examines the sequence of ids that it has received. There are three cases: 1. If the maximum id in the sequence is not unique, it abandons this phase and goes on to the next. 2. If the maximum id in the sequence is unique and is the process own id, then it outputs LEADER and halts. 3. If the maximum id in the sequence is unique and is not the process own id, then it just halts. It should be clear that, at the first phase where all the processes choose distinct ids, exactly one process elects itself the leader, and then the algorithm halts. So certainly the algorithm never elects more than one leader. At each phase, with probability at least 1/2, all the chosen ids are distinct and the algorithm terminates. Since the choices in different phases are independent, the probability 1 that the algorithm finishes within h phases is at least 1 2 h. Thus, with probability 1, it eventually finishes. We analyze the time and message complexity. Each phase consists of n rounds, and sends n 2 (single-hop) messages. Consider any ε, 0 < ε < 1. Choose h to be the 1 smallest integer such that 2 h ε, that is, h = ilg (1/ε)l. Then with probability at least 1 δ h 1 ε, the algorithm finishes within h phases, using n h rounds and n 2 h messages. That is, with probability at least 1 ε, the time complexity is at most nilg (1/ε)l and the message complexity is at most n 2 ilg (1/ε)l. (c) [10 points] Finally suppose that the processes are probabilistic and they do not know n. That is, the same algorithm must work regardless of the size of the ring in which the processes are placed. We would again like an algorithm that (a) never elects more than one leader, and (b) with probability 1, eventually elects a leader. Either give an algorithm satisfying these properties, or prove that none exists. If you give an algorithm, analyze its time and message complexity as described in Part (b). Solution: This is impossible. Suppose for contradiction that such an algorithm exists. Consider the algorithm operating in a ring S of size n, for any particular value of n. Number the processes of S as 1,..., n based on their positions in the ring, counting clockwise. Since the algorithm eventually elects a leader in ring S with probability 1, there must be at least one execution α of S that leads to some process j outputting LEADER. That is, there is some particular mapping from processes to sequences of

Problem Set 10 Solutions 3 random choices such that, in the execution α in which these choices are made, some process j is elected leader. Now consider a ring R of size 2n consisting of two half-rings R 1 and R 2, each of size n. Number the processes of R as 1,..., 2n. Then there is an execution α ' of R in which processes i and n + i in R happen to make the same random choices as process i in S. In execution α ', processes i and n + i behave exactly like process i in execution α of S. Since process j outputs LEADER in execution α, both processes j and n + j output LEADER in execution α '. This contradicts problem requirement (a). Notice that this proof shows that we can t achieve any positive election probability ε, not just probability 1. Problem 10-2. Breadth-First Search in an Asynchronous Network [25 points] The asynchronous Breadth-First Search algorithm presented in class involves corrections that could trigger the sending of many messages, resulting in worst-case message complexity O(nE) and worst-case time complexity O(diam n d), until all nodes parent variables have stabilized to correct parents in a breadth-first spanning tree. (We are not considering individual processes parent outputs here, nor global termination. We are also ignoring local processing time.) This problem involves designing a better asynchronous Breadth-First Search algorithm, one that does not make any corrections. Thus, once a process sets its parent variable, it can output the value since that is its final decision. Assume that the network graph is connected and contains at least two nodes. (a) [18 points] Describe carefully, in words, an algorithm in which the root node v 0 coordinates the construction of the tree, level by level. Your algorithm should take time O(diam 2 d) until all the parent variables are set. (Hint: The root node can conduct broadcast-convergecast waves to build the successive levels in the tree. Four types of messages should be enough, e.g., search messages that test for new nodes, parent(b) (b a Boolean) for parent/nonparent responses, and ready and done messages for broadcasting and convergecasting signals on the tree.) Solution: Node v 0 initiates successive phases of the algorithm. At each phase d, exactly the nodes at distance d from v 0 get incorporated into the BFS tree. At phase 1: Node v 0 sends search messages to all its neighbors. The neighbors record v 0 as their parent, record that they are new nodes, and send parent responses back to v 0. When v 0 receives parent responses from all its neighbors, it is ready to start phase 2. At phase d, d 2: Node v 0 broadcasts ready messages down all the branches of the tree built so far, until they reach the new nodes. Each new node sends search messages to all its neighbors. When a node receives a search message, if it does not already have a parent, it sets its

4 Problem Set 10 Solutions parent variable to the sender s id, records that it is new, and sends a parent response. If it already has a parent, it sends a nonparent response. When a new node has received responses to all its search messages, it sends a done(b) message to its parent, where b = TRUE if the node has received at least one parent response, = FALSE otherwise. The done messages get convergecast up the tree; each node sets the bit b in the message it sends to its parent to the or of the bits it received from its children. When node v 0 has received done messages from all its children, it begins phase d + 1 if any of the messages contain value 1; otherwise it halts. (b) [7 points] Analyze the time and communication complexity of your algorithm, and compare them to the costs of the asynchronous BFS algorithm presented in class. Solution: The time complexity is O(diam 2 d). Each phase takes time O(diam d), and there are O(diam) phases. The message complexity is O(E + diam n). Each edge is traversed once in each direction with search and parent messages. The ready and done messages traverse tree edges only, so there are O(n) of these per phase. Solution: If it is instructive here is some code for part (a) that we think might help understand this problem more deeply. Process v 0 State variables: for each v Γ(v 0 ), send(v), a queue, initially (search) responded Γ(v 0 ), initially newinfo, a Boolean, initially false Transitions: input receive(search) v,v0, v Γ(v 0 ) add parent(false) to send(v) input receive(parent(true)) v,v0, v Γ(v 0 ) if responded = Γ(v 0 ) then for each w Γ(v 0 ), add ready to send(w) responded :=

Problem Set 10 Solutions 5 newinfo := false input receive(done(b)) v,v0, b a Boolean, v Γ(v 0 ) newinfo := newinfo b if responded = Γ(v 0 ) and newinfo then for each w Γ(v 0 ), add ready to send(w) responded := newinfo := false output send(m) v,v0, m a message, v Γ(v 0 ) Precondition: m = head(send(v)) remove head of send(v) Process u, u = v 0 State variables: parent Γ(u) { }, initially children Γ(u), initially newnode a Boolean, initially false for each v Γ(u), send(v), a queue, initially empty responded Γ(u), initially newinfo, a Boolean, initially false Transitions: input receive(search) v,u, v Γ(u) if parent = then parent := v newnode := true add parent(true) to send(v) else add parent(false) to send(v) input receive(parent(b)) v,u, b a Boolean, v Γ(u) if b then children := children {v} newinfo := true if responded = Γ(u) then add done(newinfo) to send(parent)

6 Problem Set 10 Solutions input receive(ready) v,u, v Γ(u) if newnode then for each w Γ(u), add search to send(w) else for each w children, add ready to send(w) responded := newinfo := false input receive(done(b)) v,u, b a Boolean, v Γ(u) newinfo := newinfo b if responded = children then add done(newinfo) to send(parent) output send(m) u,v, m a message, v Γ(u) Precondition: m = head(send(v)) remove head of send(v)

MIT OpenCourseWare http://ocw.mit.edu 6.046J / 18.410J Design and Analysis of Algorithms Spring 2015 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.