/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none} Q12E Either prove or give a counterex... [FREE SOLUTION] | 91影视

91影视

Either prove or give a counterexample: if {u,v}is an edge in an undirected graph, and during depth-first search (u)<post (v), then vis an ancestor of uin the DFS tree.

Short Answer

Expert verified

If {u,v} is an edge in an undirected graph, and during the depth-first search post (u) < post(v) , then v is an ancestor of u in the DFS tree.

Step by step solution

01

Depth-first search

Depth First Search (DFS) is an application of graph traversal. It traverses the node downwards and uses the stack as a data structure through this it traverses all vertices in the downward direction one by one.

Some properties ofdepth-first search are as follows:

  1. Using DFT we can verify whether the graph is connected or not it means it detects the cycle present in the graph or not.
  2. We can find out the number of connected components by using adepth-first search.
  3. Here we are using the stack as a data structure.

The time complexity of the list is O(V+E).

The time complexity of matrix isOV2.

It contains various edges, they aretree edge, forward edge, back edge, or cross edge all the edges are explained below:

Tree edge: The graph obtained by traversing while using a depth-first search is called its tree edge.

Forward edge: the edge {u,v} whereis a descendant and it is not part of the depth-first search is called the forward edge.

Back edge: the edge {u,v} where is the ancestor and it is not part of the depth-first search is called the back edge.

02

Step 2: During DFS,post (u) < (v) , and v is an ancestor of u in the DFS tree

Consider the depth first search tree of graph G starting at any vertex. For this graph, if depth-first search is performed in the graph then if post is less than post v than, here the edge {u,v} where u is ancestor and it is not part of depth first search is called back edge. If {u,v} is an edge in an undirected graph and while performing a depth-first search in the undirected connected graph the the post (u)< post (v) , then v is an ancestor of in the DFS tree.

Here it follows these two conditions:

  1. [preu,post u] [prev.post v ]
  2. [prev,[preu,post u]post v ]

Only these options are taking place here for an undirected graph post u is less than post v. since there is an edge between these two vertices and option one is not possible because it is a must to traverse all the neighbors of a vertex before marking it as visited.

So, option two鈥檚 condition is only possible which defines the vertex v is the ancestor of u. hence an undirected graph, and during the depth-first search, post(u) < post (v),then v is an ancestor of u in the depth-first search traversal.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with 91影视!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

You are given a tree T=(V,E) (in adjacency list format), along with a designated root node rV. Recall that u is said to be an ancestor of v in the rooted tree if the path from r to v in T passes through u.

You wish to reprocess the tree so that queries of the form 鈥渋s u an ancestor v?鈥 can be answered in constant time. The pre-processing itself should take linear time. How can this be done?

Two paths in a graph are called edge-disjointif they have no edges in common. Show that in any undirected graph, it is possible to pair up the vertices of odd degree and find paths between each such pair so that all these paths are edge-disjoint.

On page 102, we defined the binary relation 鈥渃onnected鈥 on the set of vertices of a directedgraph. Show that this is an equivalence relation(see Exercise 3.29), and conclude that it partitions the vertices into disjoint strongly connected components.

Design a linear-time algorithm which, given an undirected graph G and a particular edge ein it, determines whetherGhas a cycle containing.

In the 2SAT problem, you are given a set of clauses, where each clause is the disjunction (OR) of two literals (a literal is a Boolean variable of or the negation of a Boolean variable). You are looking for a way to assign a valuetrueorfalseto each of the variables so that all clauses are satisfied- that is, there is at least one true literal in each clause. For example, here鈥檚 an instance of 2SAT:

x1x2x1x3x1x2x3x4x1x4

This instance has a satisfying assignment: set x1,x2,x3, and x4 totrue, false, false,andtrue,respectively.

  1. Are there other satisfying truth assignments of this 2SAT formula? If so, find them all.
  2. Give an instance of 2SAT with four variables, and with no satisfying assignment.

The purpose of this problem is to lead you to a way of solving 2SAT efficiently by reducing it to the problem of finding the strongly connected components of a directed graph. Given an instance l of 2SAT with n variables and m clauses, construct a directed graph GI=V,E as follows.

  • GIhas 2nnodes, one for each variable and its negation.
  • GIhas 2m edges: for each clause of l (where ,are literals), G1has an edge from the negation of to , and one from the negation of to .

Note that the clause is equivalent to either of the implications or . In this sense, data-custom-editor="chemistry" GI records all implications in l .

(C). Carry out this construction for the instance of 2SAT given above, and for the instance you constructed in (b).

(d). Show that if GI has a strongly connected component containing both x and X for some variable x , then l has no satisfying assignment.

(e). Now show the converse of (d): namely, that if none of GI鈥檚 strongly connected components contain both a literal and its negation, then the instance l must be satisfiable.(Hint: Assign values to the variables as follows: repeatedly pick a sink strongly connected component of GI. Assign valuetrueto all literals in the sink, assignfalseto their negations, and delete all of these. Show that this ends up discovering a satisfying assignment.)

(f). Conclude that there is a linear-time algorithm for solving 2SAT.

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.