<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Prosuncsedu's Blog</title>
	<atom:link href="http://prosuncsedu.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://prosuncsedu.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Thu, 29 Dec 2011 07:40:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='prosuncsedu.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Prosuncsedu's Blog</title>
		<link>http://prosuncsedu.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://prosuncsedu.wordpress.com/osd.xml" title="Prosuncsedu&#039;s Blog" />
	<atom:link rel='hub' href='http://prosuncsedu.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Speculative tomasulo, branch in the issue phase</title>
		<link>http://prosuncsedu.wordpress.com/2011/12/28/speculative-tomasulo-branch-in-the-issue-phase/</link>
		<comments>http://prosuncsedu.wordpress.com/2011/12/28/speculative-tomasulo-branch-in-the-issue-phase/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 19:59:25 +0000</pubDate>
		<dc:creator>prosun</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://prosuncsedu.wordpress.com/?p=203</guid>
		<description><![CDATA[I had confusions on SPeculative tomasulo; now, which I know the correct answer for. 1) If one branch is in issue phase in cycle (C) should we suspend other later instruction from issuing in the cycle cycle ? Ans:Yes. So, if there is a branch instruction in a cycle (say 10) issue no other later [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prosuncsedu.wordpress.com&amp;blog=5631653&amp;post=203&amp;subd=prosuncsedu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I had confusions on SPeculative tomasulo; now, which I know the correct answer for.</p>
<p>1) If one branch is in issue phase in cycle (C) should we suspend other later instruction from issuing in the cycle cycle ?</p>
<p>Ans:Yes. So, if there is a branch instruction in a cycle (say 10) issue no other later instruction in the 10th cycle.</p>
<p>2) When a reservation station becomes  free?</p>
<p>Ans: It becomes free after writing the result to CDB. Not after issuing the instruction in the functional unit.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/prosuncsedu.wordpress.com/203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/prosuncsedu.wordpress.com/203/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/prosuncsedu.wordpress.com/203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/prosuncsedu.wordpress.com/203/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/prosuncsedu.wordpress.com/203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/prosuncsedu.wordpress.com/203/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/prosuncsedu.wordpress.com/203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/prosuncsedu.wordpress.com/203/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/prosuncsedu.wordpress.com/203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/prosuncsedu.wordpress.com/203/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/prosuncsedu.wordpress.com/203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/prosuncsedu.wordpress.com/203/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/prosuncsedu.wordpress.com/203/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/prosuncsedu.wordpress.com/203/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prosuncsedu.wordpress.com&amp;blog=5631653&amp;post=203&amp;subd=prosuncsedu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://prosuncsedu.wordpress.com/2011/12/28/speculative-tomasulo-branch-in-the-issue-phase/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5bc63f96961324a6b7e12090414c341?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">prosuncsedu</media:title>
		</media:content>
	</item>
		<item>
		<title>How Tomasulo (non Speculative) avoid WAW hazard</title>
		<link>http://prosuncsedu.wordpress.com/2011/12/06/how-tomasulo-non-speculative-avoid-waw-hazard/</link>
		<comments>http://prosuncsedu.wordpress.com/2011/12/06/how-tomasulo-non-speculative-avoid-waw-hazard/#comments</comments>
		<pubDate>Tue, 06 Dec 2011 05:46:06 +0000</pubDate>
		<dc:creator>prosun</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://prosuncsedu.wordpress.com/?p=200</guid>
		<description><![CDATA[In non speculative Tomasulo, for each register, we designate how the corresponding register will get its value from. i instruction : R1 = R3 + R4 i+1   instrction : R1  = R5 + R6 when i th instruction is in progress,  R1 will mark corresponding reservation station for this instruction who will provide value for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prosuncsedu.wordpress.com&amp;blog=5631653&amp;post=200&amp;subd=prosuncsedu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In non speculative Tomasulo, for each register, we designate how the corresponding register will get its value from.</p>
<p>i instruction : R1 = R3 + R4</p>
<p>i+1   instrction : R1  = R5 + R6</p>
<p>when i th instruction is in progress,  R1 will mark corresponding reservation station for this instruction who will provide value for R1.</p>
<p>Similarly, when (i+1)th instruction, is in progress, it will later update that value of R1 will come from the reservation station associated with (i+1) instruction.</p>
<p>Thus the value of (i+1) instruction will prevail avoiding WAW hazard.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/prosuncsedu.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/prosuncsedu.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/prosuncsedu.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/prosuncsedu.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/prosuncsedu.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/prosuncsedu.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/prosuncsedu.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/prosuncsedu.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/prosuncsedu.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/prosuncsedu.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/prosuncsedu.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/prosuncsedu.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/prosuncsedu.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/prosuncsedu.wordpress.com/200/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prosuncsedu.wordpress.com&amp;blog=5631653&amp;post=200&amp;subd=prosuncsedu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://prosuncsedu.wordpress.com/2011/12/06/how-tomasulo-non-speculative-avoid-waw-hazard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5bc63f96961324a6b7e12090414c341?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">prosuncsedu</media:title>
		</media:content>
	</item>
		<item>
		<title>How Speculative Tomasulo Prevent WAW,WAR,RAW,RAR hazards?</title>
		<link>http://prosuncsedu.wordpress.com/2011/12/06/how-speculative-tomasulo-prevent-wawwarrawrar-hazards/</link>
		<comments>http://prosuncsedu.wordpress.com/2011/12/06/how-speculative-tomasulo-prevent-wawwarrawrar-hazards/#comments</comments>
		<pubDate>Tue, 06 Dec 2011 05:22:16 +0000</pubDate>
		<dc:creator>prosun</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://prosuncsedu.wordpress.com/?p=196</guid>
		<description><![CDATA[In speculative Tomasulo, the ReOrderBuffer (ROB), contains the instruction before the result of an instruction is updated in the register file. So, In oder to exist any hazard, the hazard should be in the ROB. WAW Hazard: Assume, Instruction i : R1 = R1 + R2 Instruction i+1 : R1 = R3- R4. Now, even [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prosuncsedu.wordpress.com&amp;blog=5631653&amp;post=196&amp;subd=prosuncsedu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In speculative Tomasulo, the ReOrderBuffer (ROB), contains the instruction before the result of an instruction is updated in the register file. So, In oder to exist any hazard, the hazard should be in the ROB.</p>
<p><strong>WAW Hazard:</strong></p>
<p>Assume,</p>
<p>Instruction i : R1 = R1 + R2</p>
<p>Instruction i+1 : R1 = R3- R4.</p>
<p>Now, even though, if (i+1) instruction is finished earlier before ith instruction, they are kept in the ROB first before they are commited. Now, the commit becomes in order ( first ith instruction and then (i+1) th instruction ). So, it does not matter which instruction first updated the ROB entry. This is the way, WAW hazard is removed.</p>
<p><strong>WAR:</strong></p>
<p>Assume,</p>
<p>ith instruction: R1 = R2 + R3</p>
<p>(i+1)th instruction: R2 = R5 + R6</p>
<p>In order to avoid WAR hazard, R2 must be read first by Instruction i before (i+1) instruction overwrite it.</p>
<p>It happens in Tomasulo, because, instruction is issued in Order and when an instruction is issued, the reservation station tracks down how it can get its operand from. So, As i is issued first, R2 will always be read before i+1 overwrite it.</p>
<p><strong>RAW:</strong> If there is a dependency on a register which is not yet completed, the reservation station keeps tract of which other Reservation station is going to produce it. So, it does not make RAW Hazard.</p>
<p><strong>RAR:</strong> Not a hazard anyway in Speculative tomasulo.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/prosuncsedu.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/prosuncsedu.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/prosuncsedu.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/prosuncsedu.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/prosuncsedu.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/prosuncsedu.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/prosuncsedu.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/prosuncsedu.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/prosuncsedu.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/prosuncsedu.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/prosuncsedu.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/prosuncsedu.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/prosuncsedu.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/prosuncsedu.wordpress.com/196/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prosuncsedu.wordpress.com&amp;blog=5631653&amp;post=196&amp;subd=prosuncsedu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://prosuncsedu.wordpress.com/2011/12/06/how-speculative-tomasulo-prevent-wawwarrawrar-hazards/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5bc63f96961324a6b7e12090414c341?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">prosuncsedu</media:title>
		</media:content>
	</item>
		<item>
		<title>Sort n elements, each of which is red, white, or blue on the color in the order Red, White, Blue.</title>
		<link>http://prosuncsedu.wordpress.com/2011/10/30/sort-n-elements-each-of-which-is-red-white-or-blue-on-the-color-in-the-order-red-white-blue/</link>
		<comments>http://prosuncsedu.wordpress.com/2011/10/30/sort-n-elements-each-of-which-is-red-white-or-blue-on-the-color-in-the-order-red-white-blue/#comments</comments>
		<pubDate>Sun, 30 Oct 2011 19:54:55 +0000</pubDate>
		<dc:creator>prosun</dc:creator>
				<category><![CDATA[algorithm]]></category>

		<guid isPermaLink="false">http://prosuncsedu.wordpress.com/?p=193</guid>
		<description><![CDATA[Skiena : 4-18. Suppose an array A consists of n elements, each of which is red, white, or blue. We seek to sort the elements so that all the reds come before all the whites, which come before all the bluesThe only operation permitted on the keys are Examine(A,i) &#8212; report the color of the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prosuncsedu.wordpress.com&amp;blog=5631653&amp;post=193&amp;subd=prosuncsedu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Skiena : 4-18. Suppose an array <em>A</em> consists of <em>n</em> elements, each of which is <em>red</em>, <em>white</em>, or <em>blue</em>. We seek to sort the elements so that all the <em>reds</em> come before all the <em>whites</em>, which come before all the <em>blues</em>The only operation permitted on the keys are</p>
<ol>
<li><em>Examine(A,i)</em> &#8212; report the color of the <em>i</em>th element of <em>A</em>.</li>
<li><em>Swap(A,i,j)</em> &#8212; swap the <em>i</em>th element of <em>A</em> with the <em>j</em>th element.</li>
</ol>
<p>Find a correct and efficient algorithm for red-white-blue sorting. There is a linear-time solution. This is also known as the Dutch national flag problem. The simplest linear time solution performs two passes of the partition operation from Quicksort. The first pass treats the red and white elements as indistinguishable, and separates them from the blue. The second pass is just separates the elements within the red/white sub-array.</p>
<p>Solution:</p>
<p>i1 &lt;&#8212;-Red &#8212;&gt; i2      j1 &lt;&#8212;&#8212;&#8211;White &#8212;&#8212;-&gt; j2     k1 &lt;&#8212;&#8212;-Blue &#8212;&#8212;-&gt; k2          NEXT</p>
<p>In some already sorted list, i1 is the index of first red, i2 = last red index, j1 = first white index, j2 = last white index,  k1=first blue and k2 = last blue.</p>
<p>now, the algorithm would be</p>
<p><pre class="brush: plain;">

if ( NEXT == Blue)  {NEXT ++; k2++};

if (NEXT == White) { swap(Elements[k1],Elements[NEXT];j2++;k1++;k2++;}

if ( NEXT == Red) { swap(Elements[k1],Elements[NEXT]); swap(Elements[k1],Elements[j1]); i2++;j1++;j2++;k1++;k2++}

</pre></p>
<p>for initial value assume all values i1=i2=j1=j2=k1=k2 = 0;</p>
<p>Bingo, this is O(n) complexity algorithm.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/prosuncsedu.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/prosuncsedu.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/prosuncsedu.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/prosuncsedu.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/prosuncsedu.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/prosuncsedu.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/prosuncsedu.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/prosuncsedu.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/prosuncsedu.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/prosuncsedu.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/prosuncsedu.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/prosuncsedu.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/prosuncsedu.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/prosuncsedu.wordpress.com/193/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prosuncsedu.wordpress.com&amp;blog=5631653&amp;post=193&amp;subd=prosuncsedu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://prosuncsedu.wordpress.com/2011/10/30/sort-n-elements-each-of-which-is-red-white-or-blue-on-the-color-in-the-order-red-white-blue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5bc63f96961324a6b7e12090414c341?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">prosuncsedu</media:title>
		</media:content>
	</item>
		<item>
		<title>[3] Give an eﬃcient algorithm to rearrange an array of n keys so that all the negative keys precede all the nonnegative keys.</title>
		<link>http://prosuncsedu.wordpress.com/2011/10/30/3-give-an-e%ef%ac%83cient-algorithm-to-rearrange-an-array-of-n-keys-so-that-all-the-negative-keys-precede-all-the-nonnegative-keys/</link>
		<comments>http://prosuncsedu.wordpress.com/2011/10/30/3-give-an-e%ef%ac%83cient-algorithm-to-rearrange-an-array-of-n-keys-so-that-all-the-negative-keys-precede-all-the-nonnegative-keys/#comments</comments>
		<pubDate>Sun, 30 Oct 2011 19:12:14 +0000</pubDate>
		<dc:creator>prosun</dc:creator>
				<category><![CDATA[algorithm]]></category>

		<guid isPermaLink="false">http://prosuncsedu.wordpress.com/?p=191</guid>
		<description><![CDATA[Give an eﬃcient algorithm to rearrange an array of n keys so that all the negative keys precede all the nonnegative keys. &#160; Solution: 1. Scan through the list from left to right through i . 2. Point the first positive number in the list say it  j (initially -1). 3. When List[i] is a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prosuncsedu.wordpress.com&amp;blog=5631653&amp;post=191&amp;subd=prosuncsedu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Give an eﬃcient algorithm to rearrange an array of n keys so that all the<br />
negative keys precede all the nonnegative keys. </p>
<p>&nbsp;</p>
<p>Solution:</p>
<p>1. Scan through the list from left to right through i .</p>
<p>2. Point the first positive number in the list say it  j (initially -1).</p>
<p>3. When List[i] is a negative number and j &gt;-1, swap list[i] &amp; list [j] and increment j by 1</p>
<p>4. When List[i] is a negative number and j == -1, we haven&#8217;t get any positive number and go through scanning.</p>
<p>&nbsp;</p>
<p>Complexity : O(n)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/prosuncsedu.wordpress.com/191/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/prosuncsedu.wordpress.com/191/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/prosuncsedu.wordpress.com/191/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/prosuncsedu.wordpress.com/191/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/prosuncsedu.wordpress.com/191/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/prosuncsedu.wordpress.com/191/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/prosuncsedu.wordpress.com/191/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/prosuncsedu.wordpress.com/191/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/prosuncsedu.wordpress.com/191/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/prosuncsedu.wordpress.com/191/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/prosuncsedu.wordpress.com/191/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/prosuncsedu.wordpress.com/191/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/prosuncsedu.wordpress.com/191/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/prosuncsedu.wordpress.com/191/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prosuncsedu.wordpress.com&amp;blog=5631653&amp;post=191&amp;subd=prosuncsedu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://prosuncsedu.wordpress.com/2011/10/30/3-give-an-e%ef%ac%83cient-algorithm-to-rearrange-an-array-of-n-keys-so-that-all-the-negative-keys-precede-all-the-nonnegative-keys/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5bc63f96961324a6b7e12090414c341?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">prosuncsedu</media:title>
		</media:content>
	</item>
		<item>
		<title>Determine whether there exists a path in graph G of length L.</title>
		<link>http://prosuncsedu.wordpress.com/2011/10/29/determine-whether-there-exists-a-path-in-graph-g-of-length-l/</link>
		<comments>http://prosuncsedu.wordpress.com/2011/10/29/determine-whether-there-exists-a-path-in-graph-g-of-length-l/#comments</comments>
		<pubDate>Sat, 29 Oct 2011 05:12:28 +0000</pubDate>
		<dc:creator>prosun</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://prosuncsedu.wordpress.com/?p=187</guid>
		<description><![CDATA[Determine whether there exists a path in graph G of length L. Solution: If the graph has a cycle, then the graph has a path of any length L. If the graph does not have a cycle , then we are finding a simple path of length L. We will use DFS with some modification [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prosuncsedu.wordpress.com&amp;blog=5631653&amp;post=187&amp;subd=prosuncsedu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Determine whether there exists a path in graph G of length L.</p>
<p>Solution:</p>
<p>If the graph has a cycle, then the graph has a path of any length L.</p>
<p>If the graph does not have a cycle , then we are finding a simple path of length L.</p>
<p>We will use DFS with some modification to find simple path of length L.</p>
<p>For this with every node n, we will maintain a value  named maxPath (other than start_time and end_time) which determines path of Maximum value.</p>
<p>We will initialize each nodes of G with maxPath = 0;</p>
<p>So, the steps to find simple path of Lengh L  is :</p>
<p>1. Run modified DFS-visit()</p>
<p>2. check each node for the maxPath value.</p>
<p><pre class="brush: plain;">

DFS-visit(u) {

time = time + 1

u.start = time;

for each v &lt;em&gt;belongs-to&lt;/em&gt; adj[u]

if ( v.color = WHITE ) {

DFS-visit(v)

if (u.maxPath &lt; v.maxPath + 1 )

u.maxPath = v.maxPath + 1;

}

u.endtime = time + 1;

u.color = BLACK

</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/prosuncsedu.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/prosuncsedu.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/prosuncsedu.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/prosuncsedu.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/prosuncsedu.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/prosuncsedu.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/prosuncsedu.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/prosuncsedu.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/prosuncsedu.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/prosuncsedu.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/prosuncsedu.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/prosuncsedu.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/prosuncsedu.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/prosuncsedu.wordpress.com/187/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prosuncsedu.wordpress.com&amp;blog=5631653&amp;post=187&amp;subd=prosuncsedu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://prosuncsedu.wordpress.com/2011/10/29/determine-whether-there-exists-a-path-in-graph-g-of-length-l/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5bc63f96961324a6b7e12090414c341?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">prosuncsedu</media:title>
		</media:content>
	</item>
		<item>
		<title>Consider the problem of determining whether a given undirected graph G=(V,E) contains a trinagle or cycle of length 3</title>
		<link>http://prosuncsedu.wordpress.com/2011/09/30/consider-the-problem-of-determining-whether-a-given-undirected-graph-gve-contains-a-trinagle-or-cycle-of-length-3/</link>
		<comments>http://prosuncsedu.wordpress.com/2011/09/30/consider-the-problem-of-determining-whether-a-given-undirected-graph-gve-contains-a-trinagle-or-cycle-of-length-3/#comments</comments>
		<pubDate>Fri, 30 Sep 2011 23:22:04 +0000</pubDate>
		<dc:creator>prosun</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://prosuncsedu.wordpress.com/?p=183</guid>
		<description><![CDATA[Consider the problem of determining whether a given undirected graph G=(V,E) contains a trinagle or cycle of length 3. Give o(v^3) algorithm for it. Solution: step 1: Run DFS on the given as  it is. step 2: In the DFS-visit of vertice ( say u ) run a modified BFS ( say BFS2). The algorithm [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prosuncsedu.wordpress.com&amp;blog=5631653&amp;post=183&amp;subd=prosuncsedu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Consider the problem of determining whether a given undirected graph G=(V,E) contains a trinagle or cycle of length 3.</p>
<p>Give o(v^3) algorithm for it.</p>
<p>Solution:</p>
<p>step 1: Run DFS on the given as  it is.</p>
<p>step 2: In the DFS-visit of vertice ( say u ) run a modified BFS ( say BFS2).</p>
<p>The algorithm for BFS2 is as following:</p>
<p><pre class="brush: java;">

BFS2(u) {

foreach v1 belongs to adj[u]

foreach v2 belongs to [adj[v1] - u] { // because we know u must be adjacent of v1. that's why we will not let u create massacre here.

if ( v2 and u are adjacent to each other )

Report ( u,v1,v2) as a cycle or length 3 .

}

}

</pre></p>
<p>This problem appears in algorithm design manual by skiena as following</p>
<p>5-17. Consider the problem of determining whether a given undirected graph <em>G</em> = (<em>V</em>,<em>E</em>) contains a <em>triangle</em>or cycle of length 3.</p>
<ol>
<li>Give an <em>O</em>( | <em>V</em> | <sup>3</sup>) to find a triangle if one exists.</li>
</ol>
<p>The complexity id v3 because for each vertices BFS2 will run for with v^2 complexity.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/prosuncsedu.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/prosuncsedu.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/prosuncsedu.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/prosuncsedu.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/prosuncsedu.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/prosuncsedu.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/prosuncsedu.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/prosuncsedu.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/prosuncsedu.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/prosuncsedu.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/prosuncsedu.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/prosuncsedu.wordpress.com/183/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/prosuncsedu.wordpress.com/183/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/prosuncsedu.wordpress.com/183/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prosuncsedu.wordpress.com&amp;blog=5631653&amp;post=183&amp;subd=prosuncsedu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://prosuncsedu.wordpress.com/2011/09/30/consider-the-problem-of-determining-whether-a-given-undirected-graph-gve-contains-a-trinagle-or-cycle-of-length-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5bc63f96961324a6b7e12090414c341?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">prosuncsedu</media:title>
		</media:content>
	</item>
		<item>
		<title>Find the node  of a graph from which all nodes are reachable</title>
		<link>http://prosuncsedu.wordpress.com/2011/09/30/find-the-node-of-a-graph-from-which-node-nodes-are-reachable/</link>
		<comments>http://prosuncsedu.wordpress.com/2011/09/30/find-the-node-of-a-graph-from-which-node-nodes-are-reachable/#comments</comments>
		<pubDate>Fri, 30 Sep 2011 22:28:20 +0000</pubDate>
		<dc:creator>prosun</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://prosuncsedu.wordpress.com/?p=177</guid>
		<description><![CDATA[If we have a graph G=(V,E) and all vertices are reachable from vertex s, then our problem is to find such a vertex s. Solution: Solution to this problem is in DFS of the graph. Before going to the algorithm, we need to consider the following properties of DFS. i) DFS tree produced by the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prosuncsedu.wordpress.com&amp;blog=5631653&amp;post=177&amp;subd=prosuncsedu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If we have a graph G=(V,E) and all vertices are reachable from vertex s, then our problem is to find such a vertex s.</p>
<p>Solution: Solution to this problem is in DFS of the graph. Before going to the algorithm, we need to consider the following properties of DFS.</p>
<p>i) DFS tree produced by the DFS algorithm is always a tree ( it means that it must be acyclic, whatever the graph is)</p>
<p>Here is the algorithm that reports if a given graph has a vertex from which all other vertex are reachable.</p>
<p><pre class="brush: java;">

DFS-Visit(u)

time = time + 1;

u.start_time = time;

child= 0;

Color = GRAY;

for each v belongs to adj[u] {

if ( v.color == WHITE ) {

DFS-visit(v);

child = (v.finish_time - v.start_time + 1 ) / 2;

}

}

u.finish_time = time + 1;

u.color = BLACK;

u.child = child + 1; // child include number of nodes this node visits including itself.

if ( u.child == |V| )

## Report u as source vertex ##

</pre></p>
<p>In fact, this is the solution for the following problem<br />
5-26. A <em>mother</em> vertex in a directed graph <em>G</em> = (<em>V</em>,<em>E</em>) is a vertex <em>v</em> such that all other vertices <em>G</em> can be reached by a directed path from <em>v</em>.</p>
<ol>
<li>Give an <em>O</em>(<em>n</em> + <em>m</em>) algorithm to test whether a given vertex <em>v</em> is a mother of <em>G</em>, where <em>n</em> = | <em>V</em> | and <em>m</em> = | <em>E</em> | .</li>
<li>Give an <em>O</em>(<em>n</em> + <em>m</em>) algorithm to test whether graph <em>G</em> contains a mother vertex.</li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/prosuncsedu.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/prosuncsedu.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/prosuncsedu.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/prosuncsedu.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/prosuncsedu.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/prosuncsedu.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/prosuncsedu.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/prosuncsedu.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/prosuncsedu.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/prosuncsedu.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/prosuncsedu.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/prosuncsedu.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/prosuncsedu.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/prosuncsedu.wordpress.com/177/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prosuncsedu.wordpress.com&amp;blog=5631653&amp;post=177&amp;subd=prosuncsedu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://prosuncsedu.wordpress.com/2011/09/30/find-the-node-of-a-graph-from-which-node-nodes-are-reachable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5bc63f96961324a6b7e12090414c341?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">prosuncsedu</media:title>
		</media:content>
	</item>
		<item>
		<title>Sorting of Pairwise sum</title>
		<link>http://prosuncsedu.wordpress.com/2011/09/16/sorting-of-pairwise-sum/</link>
		<comments>http://prosuncsedu.wordpress.com/2011/09/16/sorting-of-pairwise-sum/#comments</comments>
		<pubDate>Fri, 16 Sep 2011 20:40:49 +0000</pubDate>
		<dc:creator>prosun</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://prosuncsedu.wordpress.com/?p=175</guid>
		<description><![CDATA[In this problem, we have two list X &#38; Y. we have to take any element x of X and y of Y to make a pair. The problem is to sort the sum of the pair in the ascending order. if X = {100,110,130} Y = {50,75,125} the sorted pair sum would be 150, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prosuncsedu.wordpress.com&amp;blog=5631653&amp;post=175&amp;subd=prosuncsedu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In this problem, we have two list X &amp; Y. we have to take any element x of X and y of Y to make a pair. The problem is to sort the sum of the pair in the ascending order.</p>
<p>if X = {100,110,130} Y = {50,75,125} the sorted pair sum would be</p>
<p>150, 160,175,180,185,205,225.</p>
<p>The code below does this :</p>
<p>class pairwisesum {<br />
public static void main(String [] s) {</p>
<p>int [] X = {100,110,130};<br />
int [] Y = {50,75,125};<br />
int [] index = {0,0,0};<br />
int sum ,next;<br />
for ( int k=0; k&lt;X.length*Y.length;  k++) {<br />
sum = 99999;<br />
next = 0;</p>
<p>for (int i=0; i&lt;X.length; i++) {<br />
//System.out.println(index[i]);<br />
if ( X[i] + Y[index[i]] &lt; sum ){<br />
sum = X[i] + Y[index[i]];<br />
next = i;<br />
}</p>
<p>}<br />
index[next] ++;<br />
System.out.println( &#8220;&#8221; + sum + &#8220;::&#8221; + next );<br />
}</p>
<p>}</p>
<p>}</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/prosuncsedu.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/prosuncsedu.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/prosuncsedu.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/prosuncsedu.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/prosuncsedu.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/prosuncsedu.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/prosuncsedu.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/prosuncsedu.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/prosuncsedu.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/prosuncsedu.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/prosuncsedu.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/prosuncsedu.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/prosuncsedu.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/prosuncsedu.wordpress.com/175/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prosuncsedu.wordpress.com&amp;blog=5631653&amp;post=175&amp;subd=prosuncsedu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://prosuncsedu.wordpress.com/2011/09/16/sorting-of-pairwise-sum/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5bc63f96961324a6b7e12090414c341?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">prosuncsedu</media:title>
		</media:content>
	</item>
		<item>
		<title>ancestor reporting in a tree</title>
		<link>http://prosuncsedu.wordpress.com/2011/09/16/ancestor-reporting-in-a-tree/</link>
		<comments>http://prosuncsedu.wordpress.com/2011/09/16/ancestor-reporting-in-a-tree/#comments</comments>
		<pubDate>Fri, 16 Sep 2011 15:14:18 +0000</pubDate>
		<dc:creator>prosun</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[s dasgupta 3.18]]></category>
		<category><![CDATA[solution ancestor]]></category>
		<category><![CDATA[tree]]></category>

		<guid isPermaLink="false">http://prosuncsedu.wordpress.com/?p=171</guid>
		<description><![CDATA[S Dasgupta- 3.18 :You are given a binary tree T = (V;E) (in adjacency list format), along with a designated root  node r belongs to V . 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 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prosuncsedu.wordpress.com&amp;blog=5631653&amp;post=171&amp;subd=prosuncsedu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>S Dasgupta- 3.18 :You are given a binary tree T = (V;E) (in adjacency list format), along with a designated root  node r belongs to V . 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 preprocess the tree so that queries of the form &#8220;is u an ancestor of v?&#8221; can be answered in constant time. The preprocessing itself should take linear time. How can this be done?</p>
<p>Solution:</p>
<p>Let Ancestor[n][n] be an two dimentional array. If there is a query &#8220;is u an ancestor of v&#8221; our program will answer &#8220;yes&#8221; if A[u][v] is true otherwise it will report &#8220;no&#8221;.</p>
<p>Algorithm:</p>
<p>DFS-visit ( u , list){</p>
<p>Process_ancestor();</p>
<p>time = time + 1</p>
<p>u.color = GRAY;</p>
<p>foreach v belongs to adj[u] {</p>
<p>append(list,v);</p>
<p>DFS-visit (v,list);</p>
<p>remove_last_element(); // which will remove v from the end of the list.</p>
<p>}</p>
<p>}</p>
<p>Process_parent ( list ) {</p>
<p>if ( list.size &gt; 1 ) {</p>
<p>for ( i=1; i&lt;=list.size; i++) {</p>
<p>for ( j=i+1; j&lt;=list.size; j++)</p>
<p>ancestor[list[i]][list[j]] = true; // list[i] is a ancestor of list[j]</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p>Process_query( u,v) {   // This will answer our question.</p>
<p>if ( ancestor[u][v] == true ) return yes;</p>
<p>return false;</p>
<p>}</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/prosuncsedu.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/prosuncsedu.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/prosuncsedu.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/prosuncsedu.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/prosuncsedu.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/prosuncsedu.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/prosuncsedu.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/prosuncsedu.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/prosuncsedu.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/prosuncsedu.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/prosuncsedu.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/prosuncsedu.wordpress.com/171/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/prosuncsedu.wordpress.com/171/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/prosuncsedu.wordpress.com/171/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=prosuncsedu.wordpress.com&amp;blog=5631653&amp;post=171&amp;subd=prosuncsedu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://prosuncsedu.wordpress.com/2011/09/16/ancestor-reporting-in-a-tree/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5bc63f96961324a6b7e12090414c341?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">prosuncsedu</media:title>
		</media:content>
	</item>
	</channel>
</rss>
