how will you solve these questions ?
From: blandet2 (ahmedrakha_at_gmail.com)
Date: 03/14/05
- Next message: Matthew Huntbach: "Re: Minsky still posting"
- Previous message: Torkel Franzen: "Re: Minsky still posting"
- Next in thread: Djamé Seddah: "Re: how will you solve these questions ?"
- Reply: Djamé Seddah: "Re: how will you solve these questions ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 14 Mar 2005 07:55:54 -0800
Consider an undirected and connected graph G =(V,E) with at least two
vertices.
We assume that G is given by an adjacency-list representation. An
orientation of G is an assignment of directions to the (undirected)
edges in G so as to produce a directed graph. A balanced orientation
is an orientation of G for which every vertex has at least one
in-going and at least one out-going edge (this condition only applies
to vertices that have at least two incident edges).
In this exercise we develop a O(V+E) time algorithm that constructs a
balanced orientation of G. The algorithm is as follows:
1. Pick a vertex r in G that either has degree 1 or is part of some
cycle in G.
2. Perform a depth-first search from r in G. The orientation of G is
obtained as follows. A tree edge (u,v) is oriented from u to v (v was
first
discovered by exploring edge (u,v)). A back edge (u,v)is oriented from
u to v if v is an ancestor of u in the depth-first tree.
Exercise 1
Prove that a vertex with the given properties always exists, and give
a O(V) time algorithm to find such a vertex.
Exercise 2
Prove that the output of the proposed algorithm is a balanced
orientation, and that the algorithm runs on O(V+E). Hint: Handle r as
a special case when proving that the output is a balanced orientation.
Exercise 3
Show that the algorithm could fail if r is an arbitrary vertex in G.
- Next message: Matthew Huntbach: "Re: Minsky still posting"
- Previous message: Torkel Franzen: "Re: Minsky still posting"
- Next in thread: Djamé Seddah: "Re: how will you solve these questions ?"
- Reply: Djamé Seddah: "Re: how will you solve these questions ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|