Problem 2 [20 points]. Consider the graphs on the right, which we denote as a cy
ID: 3756283 • Letter: P
Question
Problem 2 [20 points]. Consider the graphs on the right, which we denote as a cycle and an in finite diamond strip (IDS). The cycle has n nodes V1, , vn-to that are consecutively ordered, i.e., vi has vi-i bors, with vi-1 before vi+1 mod n. node in the IDS, assume that in its adjacency list, the neighbors on the left appear before the neighbors on the right. Now consider running BFS and DFS tree and graph searches on these two graphs. For the cycle graph, suppose the start node is x1 ui and the goal node is zG = zk, 1 S kExplanation / Answer
This problem know as Hamiltonian cycle problem (HCP). This has been classified as NP-hardness. Let me explain you some cases along with time complexity. Both BFS and DFS will require O (V+E) time only.
But if you put a circuit in a Tree, DFS always hit the cycle until and unless it reaches half of the tree. And that half tree is already been traverse as we had gone in depth first, instead of level. So the time will be like n/2*n/2+n/2*3n/4<=n in all the cases. But in case of BFS in tree we will require much time in layer evaluation. We will not go to the end unless we finish all the layers. That too would be very costly.
Let me process our example, BFS will be efficient in IDS, and DFS will be easy in Cycle. But still as they both are NP complete problem memory will require much-2 higher.
Anyway cycle will be easy in case of DFS, and IDS will be easy in case of BFS algorithm.
We don’t need infinite space to solve this problem. An infinite union of thin families always can’t be a, even if the sum if family is. Therefor we can say we don’t need infinite space.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.