Suppose that a black stone is placed on a vertex s and a white stone is placed o
ID: 3591894 • Letter: S
Question
Suppose that a black stone is placed on a vertex s and a white stone is placed on a dierent node t of an undirected graph G, where there is no edge between s and t. At every step, we have to move both stones simultaneously to two new non-adjacent (dierent) vertices. A stone can only be moved from a node to a neighbouring node. The ultimate goal is to switch the places of the two stones. That is to have the black stone on t and the white stone on s. Design an algorithm that takes as input G and s and t, and tells whether this is possible, and if it is, then what is the minimum number of steps required to achieve this.
Explanation / Answer
As per given requirement if we add more than one node in this graph,we should add like one each for both left and right sides then only given two coloured stones will interchange.We can also use both ways seperately with any of stone that is travelling and they can interchanged as per conditions thhat must need to safisfy.For this methhod it takes minimum of 4 basic steps to achieve this.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.