CIS 540 Fall 2009 Homework 2 Solutions

Similar documents
1 Solutions to Tute09

Homework #4. CMSC351 - Spring 2013 PRINT Name : Due: Thu Apr 16 th at the start of class

Notes on Natural Logic

PARELLIZATION OF DIJKSTRA S ALGORITHM: COMPARISON OF VARIOUS PRIORITY QUEUES

Binary Decision Diagrams

SET 1C Binary Trees. 2. (i) Define the height of a binary tree or subtree and also define a height balanced (AVL) tree. (2)

CHAPTER 4 MANAGING STRATEGIC CAPACITY 1

Binary Decision Diagrams

CS 798: Homework Assignment 4 (Game Theory)

Max Registers, Counters and Monotone Circuits

Microeconomics of Banking: Lecture 5

GAME THEORY: DYNAMIC. MICROECONOMICS Principles and Analysis Frank Cowell. Frank Cowell: Dynamic Game Theory

Information Theory and Coding Prof. S. N. Merchant Department of Electrical Engineering Indian Institute of Technology, Bombay

Optimal Satisficing Tree Searches

Handout 4: Deterministic Systems and the Shortest Path Problem

Recall: Data Flow Analysis. Data Flow Analysis Recall: Data Flow Equations. Forward Data Flow, Again

CUR 412: Game Theory and its Applications, Lecture 9

On the Optimality of a Family of Binary Trees Techical Report TR

PRIORITY QUEUES. binary heaps d-ary heaps binomial heaps Fibonacci heaps. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley

3/7/13. Binomial Tree. Binomial Tree. Binomial Tree. Binomial Tree. Number of nodes with respect to k? N(B o ) = 1 N(B k ) = 2 N(B k-1 ) = 2 k

Algorithms PRIORITY QUEUES. binary heaps d-ary heaps binomial heaps Fibonacci heaps. binary heaps d-ary heaps binomial heaps Fibonacci heaps

MBF1413 Quantitative Methods

UNIT VI TREES. Marks - 14

CSE 21 Winter 2016 Homework 6 Due: Wednesday, May 11, 2016 at 11:59pm. Instructions

Dynamic Programming: An overview. 1 Preliminaries: The basic principle underlying dynamic programming

Lattices and the Knaster-Tarski Theorem

Crash-tolerant Consensus in Directed Graph Revisited

Lecture 5 Leadership and Reputation

IEOR E4004: Introduction to OR: Deterministic Models

CSE 100: TREAPS AND RANDOMIZED SEARCH TREES

2 all subsequent nodes. 252 all subsequent nodes. 401 all subsequent nodes. 398 all subsequent nodes. 330 all subsequent nodes

Tree Diagram. Splitting Criterion. Splitting Criterion. Introduction. Building a Decision Tree. MS4424 Data Mining & Modelling Decision Tree

AVL Trees. The height of the left subtree can differ from the height of the right subtree by at most 1.

DRAFT. 1 exercise in state (S, t), π(s, t) = 0 do not exercise in state (S, t) Review of the Risk Neutral Stock Dynamics

Another Variant of 3sat. 3sat. 3sat Is NP-Complete. The Proof (concluded)

Principles of Program Analysis: Algorithms

Initializing A Max Heap. Initializing A Max Heap

CEC login. Student Details Name SOLUTIONS

Rational Behaviour and Strategy Construction in Infinite Multiplayer Games

Priority Queues 9/10. Binary heaps Leftist heaps Binomial heaps Fibonacci heaps

Yao s Minimax Principle

Lecture l(x) 1. (1) x X

Introduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Splay Trees Date: 9/27/16

15-451/651: Design & Analysis of Algorithms October 23, 2018 Lecture #16: Online Algorithms last changed: October 22, 2018

CSCE 750, Fall 2009 Quizzes with Answers

Math 167: Mathematical Game Theory Instructor: Alpár R. Mészáros

Zero-Knowledge Arguments for Lattice-Based Accumulators: Logarithmic-Size Ring Signatures and Group Signatures without Trapdoors

Design and Analysis of Algorithms 演算法設計與分析. Lecture 9 November 19, 2014 洪國寶

Finitely repeated simultaneous move game.

0/1 knapsack problem knapsack problem

An effective perfect-set theorem

UNIVERSITY OF OSLO. Faculty of Mathematics and Natural Sciences

Sublinear Time Algorithms Oct 19, Lecture 1

Essays on Some Combinatorial Optimization Problems with Interval Data

Regret Minimization and Security Strategies

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

Maximizing the Spread of Influence through a Social Network Problem/Motivation: Suppose we want to market a product or promote an idea or behavior in

Strong normalisation and the typed lambda calculus

Outline for this Week

4 Martingales in Discrete-Time

Chapter 16. Binary Search Trees (BSTs)

Inference in Bayesian Networks

Binary and Binomial Heaps. Disclaimer: these slides were adapted from the ones by Kevin Wayne

GAME THEORY. Department of Economics, MIT, Follow Muhamet s slides. We need the following result for future reference.

Ch 10 Trees. Introduction to Trees. Tree Representations. Binary Tree Nodes. Tree Traversals. Binary Search Trees

On the Optimality of a Family of Binary Trees

Design and Analysis of Algorithms. Lecture 9 November 20, 2013 洪國寶

Design and Analysis of Algorithms 演算法設計與分析. Lecture 8 November 16, 2016 洪國寶

Computing Unsatisfiable k-sat Instances with Few Occurrences per Variable

Corporate Finance, Module 21: Option Valuation. Practice Problems. (The attached PDF file has better formatting.) Updated: July 7, 2005

It is used when neither the TX nor RX knows anything about the statistics of the source sequence at the start of the transmission

Math489/889 Stochastic Processes and Advanced Mathematical Finance Homework 4

The illustrated zoo of order-preserving functions

Introduction to Greedy Algorithms: Huffman Codes

L3. Blockchains and Cryptocurrencies

CHAPTER 12 APPENDIX Valuing Some More Real Options

The potential function φ for the amortized analysis of an operation on Fibonacci heap at time (iteration) i is given by the following equation:

Strategic Production Game 1

COMP Analysis of Algorithms & Data Structures

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

CTL Model Checking. Goal Method for proving M sat σ, where M is a Kripke structure and σ is a CTL formula. Approach Model checking!

is a path in the graph from node i to node i k provided that each of(i i), (i i) through (i k; i k )isan arc in the graph. This path has k ; arcs in i

monotone circuit value

Exercises Solutions: Game Theory

The mathematical definitions are given on screen.

16 MAKING SIMPLE DECISIONS

Multirate Multicast Service Provisioning I: An Algorithm for Optimal Price Splitting Along Multicast Trees

Computing Unsatisfiable k-sat Instances with Few Occurrences per Variable

UNIT 2. Greedy Method GENERAL METHOD

16 MAKING SIMPLE DECISIONS

COMPUTER SCIENCE 20, SPRING 2014 Homework Problems Recursive Definitions, Structural Induction, States and Invariants

COSC160: Data Structures Binary Trees. Jeremy Bolton, PhD Assistant Teaching Professor

Counting Basics. Venn diagrams

Dynamic Games. Econ 400. University of Notre Dame. Econ 400 (ND) Dynamic Games 1 / 18

Priority Queues. Fibonacci Heap

MSU CSE Spring 2011 Exam 2-ANSWERS

Fibonacci Heaps Y Y o o u u c c an an s s u u b b m miitt P P ro ro b blle e m m S S et et 3 3 iin n t t h h e e b b o o x x u u p p fro fro n n tt..

Chapter 5: Algorithms

Chapter 11: Dynamic Games and First and Second Movers

Game Theory and Economics Prof. Dr. Debarshi Das Department of Humanities and Social Sciences Indian Institute of Technology, Guwahati.

Transcription:

CIS 54 Fall 29 Homework 2 Solutions October 25, 29 Problem (a) We can choose a simple ordering for the variables: < x 2 < x 3 < x 4. The resulting OBDD is given in Fig.. x 2 x 2 x 3 x 4 x 3 Figure : OBDD of Problem a. The size of the OBDD can be reduced by reordering the variables: x 2 < x 3 < x 4 <. The new OBDD is given in Fig. 2. This OBDD has optimal size because each variable corresponds to exactly one node in x 2 x 3 x 4 Figure 2: Size-reduced OBDD of Problem a the diagram. The diagram has four nodes for four variables and two nodes for the constants and.

(b) The expressions for z, z and c can be written as: ϕ := [z = x y ] ϕ := [z = (x y ( y )) (( x y ) ( y ))] ϕ c := [c = ( y ) (x y ( y ))] where is the exclusive or operator: a b = (a b) ( a b). The complete expression is then ϕ = ϕ ϕ ϕ c. In order to obtain an optimal ordering of the variables, we consider the dependency between the variables. We note that: The value of z depends on both x and y ; The value of z depends on all x, y, and y ; The value of c depends on x, y, and y, but in some cases, the value is decided when x, y and either or y are known; The order between x and y, and y are not important because the roles of the variables in each pair are symmetric. From the above observations, we can choose an optimal ordering as follows: x < y < z < < c < y < z. The resulting OBDD is given in Fig. 3. Problem 2 (a) The process Split has one input queue (x) and two output queues (y and y 2 ); it transfers messages from x to y and y 2 in a nondeterministic manner. Input variables: msg in Output variables: msg out,out 2 queue(msg) x,y,y 2 : x = null y = null y 2 = null A in : [ Full(x) x = Enqueue(in,x) same(y,y 2 )] A out : [ Empty(y ) out = Front(y ) y = Dequeue(y ) same(x,y 2 )] A out2 : [ Empty(y 2 ) out 2 = Front(y 2 ) y 2 = Dequeue(y 2 ) same(x,y )] A : [ Empty(x) Full(y ) y = Enqueue(Front(x),y ) x = Dequeue(x) same(y 2 )] A 2 : [ Empty(x) Full(y 2 ) y 2 = Enqueue(Front(x),y 2 ) x = Dequeue(x) same(y )] Internal actions A and A 2 transfer messages in the input queue x to output queues y and y 2, respectively, when x is not empty and the corresponding output queue is not full. (b) The fairness specification is as follows: Weak fairness for output actions A out and A out2 because whenever the corresponding output queue is not empty, the action must eventually be executed to output the messages in the queue to the output channel. 2

x y y z z z c c c y y y z z Figure 3: OBDD of Problem b 3

Strong fairness for internal actions A and A 2 because we want to prevent the situation where A 2 (A ) is repeatedly executed, causing A (A 2 ) repeatedly enabled but not executed. In other words, if A (A 2 ) is repeatedly enabled then it must be repeatedly taken. Problem 3 Note: the problem becomes very simple if the value set is the Boolean set: for any number of processes, only a single StickyBit is needed. In this solutions, we consider the case where the value set can be any set, which is more complicated and more interesting. (a) The StickyBit shared object has a nice property: the first process that writes to the object will have the decision on the value of the object. We utilize this property to implement a protocol for consensus of processes. Let s say we have two processes, P and P, with respective initial values v and v of the same type. We will use two atomic registers x and (whose value sets are the same as the type of v and v ), and a single StickyBit s. Each process performs the following sequence of steps, where i =,:. Write its initial value v i to register x i. 2. Write i to s. 3. Read the value j from s. 4. Read the value d from x j, then set its decision value d i to d. The protocol satisfies the three requirements of consensus: Agreement: The first process that writes to s will decide the value of s, either (if process P writes first) or (if process P writes first). Both processes agree on the value j of s, hence agree on the decision value d read from x j. Note that the value of x j must be not null because the process P j had written v j to x j before it wrote to s. Validity: Clearly, the decision value d is the value of either x or, which is the initial value of either P or P. Wait-freedom: If only one process P i is repeatedly executed, clearly it will decide on its initial value v i, and the other process, when it is executed, will also decide on this value. (b) For n processes, denoted P to P n, we can solve the consensus problem using multiple StickyBit and AtomicReg objects. As in (a), we use n atomic registers, to x n, to store the initial values of the n processes. The tricky part is to decide on which register the processes will agree. We cannot use StickyBit in a simple way as in part (a). Instead, we build a binary tree whose n leaf nodes correspond to the n processes and whose n other nodes correspond to StickyBit objects. For example, a binary tree for a consensus problem with 5 processes can be built as in Fig. 4, in which there are four StickyBit objects s, s 2, s 3, s 4. The idea is to decide on a (unique) path from the root node to a leaf node, represented by the values of the StickyBit objects. For example, if the values of s, s 2, s 3, s 4 are,,, respectively then the decision path is s s 2 s 4 P 3 and the decision value will be the initial value of P 3. The decision path will be built up from the leaf nodes to the root node in the following consensus protocol for each process P i, i =,...,n: 4

s s 2 s 3 s 4 P P 2 P 3 P 4 P 5 Figure 4: Binary tree for a consensus problem with 5 processes (Problem 3b).. The process writes its initial value v i to register x i. 2. Suppose that in the binary tree, the path from the root node to the leaf node P i is s j s j2 s jk P i for k. The process then follows this path from s jk up to s j and writes to the StickyBit object s jm, m = k,...,, the value if the sub-path s jm+ P i is on the right of s jm, and the value otherwise. 3. The process reads the values of the StickyBit objects, starting from the root node, and follows the path until it reaches a leaf node P j. The decision value d i is then the value read from the register x j. The protocol satisfies the three requirements of consensus: Agreement: When the StickyBit object corresponding to the root node is written, a unique path in the binary tree from the root node to a leaf node is defined. Because every StickyBit object retains its value once it is written, this decision path is fixed. Each process then reads this path from the tree and extracts the decision leaf node P j. The initial value of P j is then the decision value on which all processes agree. Note that v j had been written to x j before process P j wrote to its parent node (which is a StickyBit object). Validity: Clearly, the decision value d is the value of one of the initial values of the processes. Wait-freedom: If only one process P i is repeatedly executed, clearly it will decide on its initial value v i, and the other processes, when executed, will also decide on this value. Problem 4 (a) The status of the processes after each phase are summarized in the following table. Phase Active nodes at end of phase ([new ID]([original ID])) 25(3), 9(8), 4(4), 22(2), 24() 2 25(8) Therefore, the process whose original ID is 8 will be elected as the leader. (b) The best-case scenario happens when the identifiers of the processes are in a monotonically increasing or decreasing order. After the first round, only one node remains active, which is the one after the node 5

with the highest identifier. As an example, consider the following ring of nodes where the identifiers of the processes in the order in which they are connected are:,2,4,6,7,8,,3,4,9. After the first round, the only node staying active is the one with original identifier. The worst-case scenario is more complicated. Assume that the identifiers of the processes are,2,...,n where n is a power of 2. We would like to place the nodes in the ring so that: after the first phase, the nodes with identifiers,..., n 2 become inactive; after the second phase, the nodes with identifiers n 2 +,..., 3n 4 become inactive; and so on. We will place the nodes in the ring backward from the final phase to the first phase, as following: First, place the two final nodes in the increasing order: n,n. Place the next two nodes (n 3 and n 2), in the increasing order, interleaving between the two final nodes: n 3, n, n 2, n. Place the next four nodes (n 7 to n 4), in the increasing order, interleaving between the four already-placed nodes: n 7, n 3, n 6, n, n 5, n 2, n 4, n. Repeat the step with the next eight nodes, then the next sixteen nodes, and so on until all nodes are placed in the ring. As an example, consider the 6 nodes in part (a). We can re-order them to create a worst-case scenario as follows:, 5, 3, 22, 4, 8, 6, 24, 7, 9, 8, 23,, 2, 4, 25. It is easy to verify that after each phase, exactly half of the processes continue to stay active. 6