<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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: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>Comments on: Algorithm Problem &#8211; Binary Tree to List</title>
	<atom:link href="http://nirmalthacker.wordpress.com/2007/03/31/algorithm-problem-binary-tree-to-list/feed/" rel="self" type="application/rss+xml" />
	<link>http://nirmalthacker.wordpress.com/2007/03/31/algorithm-problem-binary-tree-to-list/</link>
	<description></description>
	<lastBuildDate>Sat, 08 Aug 2009 01:10:38 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: kristian lejao</title>
		<link>http://nirmalthacker.wordpress.com/2007/03/31/algorithm-problem-binary-tree-to-list/#comment-1596</link>
		<dc:creator>kristian lejao</dc:creator>
		<pubDate>Mon, 20 Apr 2009 01:37:00 +0000</pubDate>
		<guid isPermaLink="false">http://nirmalthacker.wordpress.com/2007/03/31/algorithm-problem-binary-tree-to-list/#comment-1596</guid>
		<description>Oops! Nevermind</description>
		<content:encoded><![CDATA[<p>Oops! Nevermind</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kristian lejao</title>
		<link>http://nirmalthacker.wordpress.com/2007/03/31/algorithm-problem-binary-tree-to-list/#comment-1594</link>
		<dc:creator>kristian lejao</dc:creator>
		<pubDate>Fri, 20 Feb 2009 17:09:06 +0000</pubDate>
		<guid isPermaLink="false">http://nirmalthacker.wordpress.com/2007/03/31/algorithm-problem-binary-tree-to-list/#comment-1594</guid>
		<description>I think I got a solution from this using Python.. :P

def to_list(tree):
     if tree is None:
        return None
     else:
        return [tree.key, tree.left, tree.right]</description>
		<content:encoded><![CDATA[<p>I think I got a solution from this using Python.. <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>def to_list(tree):<br />
     if tree is None:<br />
        return None<br />
     else:<br />
        return [tree.key, tree.left, tree.right]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ytik ytkyt</title>
		<link>http://nirmalthacker.wordpress.com/2007/03/31/algorithm-problem-binary-tree-to-list/#comment-1582</link>
		<dc:creator>ytik ytkyt</dc:creator>
		<pubDate>Fri, 08 Aug 2008 11:35:35 +0000</pubDate>
		<guid isPermaLink="false">http://nirmalthacker.wordpress.com/2007/03/31/algorithm-problem-binary-tree-to-list/#comment-1582</guid>
		<description>wt?</description>
		<content:encoded><![CDATA[<p>wt?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: amod</title>
		<link>http://nirmalthacker.wordpress.com/2007/03/31/algorithm-problem-binary-tree-to-list/#comment-1550</link>
		<dc:creator>amod</dc:creator>
		<pubDate>Thu, 01 May 2008 03:38:16 +0000</pubDate>
		<guid isPermaLink="false">http://nirmalthacker.wordpress.com/2007/03/31/algorithm-problem-binary-tree-to-list/#comment-1550</guid>
		<description>How about the following (based on inorder walk).

// explore returns a circular linked list // at each level.
explore(node):
  lnode = explore(node.left)
  lnode.left.right = node
  node.left = lnode.left 
  rnode = explore(node.right)
  rnode.left.right = lnode
  lnode.left = rnode.left
  rnode.left = node  
  node.right = rnode
  return lnode

this runs in O(n) and works for a perfectly balanced tree. For an imbalanced tree we&#039;ll need to create self loops if a left/right child is missing. I didn&#039;t test this thoroughly but it seems to work.</description>
		<content:encoded><![CDATA[<p>How about the following (based on inorder walk).</p>
<p>// explore returns a circular linked list // at each level.<br />
explore(node):<br />
  lnode = explore(node.left)<br />
  lnode.left.right = node<br />
  node.left = lnode.left<br />
  rnode = explore(node.right)<br />
  rnode.left.right = lnode<br />
  lnode.left = rnode.left<br />
  rnode.left = node<br />
  node.right = rnode<br />
  return lnode</p>
<p>this runs in O(n) and works for a perfectly balanced tree. For an imbalanced tree we&#8217;ll need to create self loops if a left/right child is missing. I didn&#8217;t test this thoroughly but it seems to work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sunil Jagadish</title>
		<link>http://nirmalthacker.wordpress.com/2007/03/31/algorithm-problem-binary-tree-to-list/#comment-932</link>
		<dc:creator>Sunil Jagadish</dc:creator>
		<pubDate>Thu, 14 Jun 2007 16:01:24 +0000</pubDate>
		<guid isPermaLink="false">http://nirmalthacker.wordpress.com/2007/03/31/algorithm-problem-binary-tree-to-list/#comment-932</guid>
		<description>The very order 1, 2, 3, 4, 5 indicates that what you require is in in-order. Though I haven&#039;t thought strongly about its exact implmentation, I think this should be possible.</description>
		<content:encoded><![CDATA[<p>The very order 1, 2, 3, 4, 5 indicates that what you require is in in-order. Though I haven&#8217;t thought strongly about its exact implmentation, I think this should be possible.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Binary Tree to List- Solutions.. &#171; the madcap laughs&#8230;..</title>
		<link>http://nirmalthacker.wordpress.com/2007/03/31/algorithm-problem-binary-tree-to-list/#comment-96</link>
		<dc:creator>Binary Tree to List- Solutions.. &#171; the madcap laughs&#8230;..</dc:creator>
		<pubDate>Tue, 03 Apr 2007 05:35:34 +0000</pubDate>
		<guid isPermaLink="false">http://nirmalthacker.wordpress.com/2007/03/31/algorithm-problem-binary-tree-to-list/#comment-96</guid>
		<description>[...] on April 3rd, 2007. Zaki has presented an interesting perspective at the original problem [...]</description>
		<content:encoded><![CDATA[<p>[...] on April 3rd, 2007. Zaki has presented an interesting perspective at the original problem [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nirmal</title>
		<link>http://nirmalthacker.wordpress.com/2007/03/31/algorithm-problem-binary-tree-to-list/#comment-95</link>
		<dc:creator>Nirmal</dc:creator>
		<pubDate>Tue, 03 Apr 2007 05:09:39 +0000</pubDate>
		<guid isPermaLink="false">http://nirmalthacker.wordpress.com/2007/03/31/algorithm-problem-binary-tree-to-list/#comment-95</guid>
		<description>yes, i did have a graph theory course at college, however i&#039;ve not tried many algorithms with graph theory concepts... 
an avl and the red-black would be below O(n) i agree...</description>
		<content:encoded><![CDATA[<p>yes, i did have a graph theory course at college, however i&#8217;ve not tried many algorithms with graph theory concepts&#8230;<br />
an avl and the red-black would be below O(n) i agree&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zakimirza</title>
		<link>http://nirmalthacker.wordpress.com/2007/03/31/algorithm-problem-binary-tree-to-list/#comment-92</link>
		<dc:creator>zakimirza</dc:creator>
		<pubDate>Sun, 01 Apr 2007 20:02:49 +0000</pubDate>
		<guid isPermaLink="false">http://nirmalthacker.wordpress.com/2007/03/31/algorithm-problem-binary-tree-to-list/#comment-92</guid>
		<description>that asks for another quiz btw :) given two differnt trees, convert between them OPTIMALLY. have you worked on graph drawing? this kind of problems arise there sparingly. For example, give a very dense graph, you might want to visualize it in different ways etc.</description>
		<content:encoded><![CDATA[<p>that asks for another quiz btw <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  given two differnt trees, convert between them OPTIMALLY. have you worked on graph drawing? this kind of problems arise there sparingly. For example, give a very dense graph, you might want to visualize it in different ways etc.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zakimirza</title>
		<link>http://nirmalthacker.wordpress.com/2007/03/31/algorithm-problem-binary-tree-to-list/#comment-91</link>
		<dc:creator>zakimirza</dc:creator>
		<pubDate>Sun, 01 Apr 2007 20:00:11 +0000</pubDate>
		<guid isPermaLink="false">http://nirmalthacker.wordpress.com/2007/03/31/algorithm-problem-binary-tree-to-list/#comment-91</guid>
		<description>Thank you for appriciating my blog. I think the efficiency in the worst case can be when the three is totally balanced. it would be fun to see how this bahaves on a  AVL or redblack. But its gotta be some factor below n for sure. lets c.</description>
		<content:encoded><![CDATA[<p>Thank you for appriciating my blog. I think the efficiency in the worst case can be when the three is totally balanced. it would be fun to see how this bahaves on a  AVL or redblack. But its gotta be some factor below n for sure. lets c.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nirmal</title>
		<link>http://nirmalthacker.wordpress.com/2007/03/31/algorithm-problem-binary-tree-to-list/#comment-88</link>
		<dc:creator>Nirmal</dc:creator>
		<pubDate>Sun, 01 Apr 2007 04:02:19 +0000</pubDate>
		<guid isPermaLink="false">http://nirmalthacker.wordpress.com/2007/03/31/algorithm-problem-binary-tree-to-list/#comment-88</guid>
		<description>Zaki, interesting technique!.. besides examining the efficiency of your algorithm would be a subject of another post..its really interesting cause i jus realized that given two different binary search trees on a given set of n keys, it is always possible to transform one tree into the other, using only a sequence of O(n) rotations. However since your recursive function digs into the tree... and now i wanna experiment this with several trees...and pulls out balance trees, converts them into a list, im wondering if the efficiency would be decent.
Nevertheless , its a super perspective.

Your blog is sure good! Great post here! http://zakimirza.wordpress.com/2007/03/28/about-quizes-and-blog/</description>
		<content:encoded><![CDATA[<p>Zaki, interesting technique!.. besides examining the efficiency of your algorithm would be a subject of another post..its really interesting cause i jus realized that given two different binary search trees on a given set of n keys, it is always possible to transform one tree into the other, using only a sequence of O(n) rotations. However since your recursive function digs into the tree&#8230; and now i wanna experiment this with several trees&#8230;and pulls out balance trees, converts them into a list, im wondering if the efficiency would be decent.<br />
Nevertheless , its a super perspective.</p>
<p>Your blog is sure good! Great post here! <a href="http://zakimirza.wordpress.com/2007/03/28/about-quizes-and-blog/" rel="nofollow">http://zakimirza.wordpress.com/2007/03/28/about-quizes-and-blog/</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
