<?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/"
		>
<channel>
	<title>Comments on: Tutorial: Johnny and the Beanstalk (A2 Review)</title>
	<atom:link href="http://blog.codechef.com/2009/03/17/johnny-and-the-beanstalk/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.codechef.com/2009/03/17/johnny-and-the-beanstalk/</link>
	<description>Practice. Compete. Discuss.</description>
	<lastBuildDate>Sun, 12 Feb 2012 15:11:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: EkramPrashanta</title>
		<link>http://blog.codechef.com/2009/03/17/johnny-and-the-beanstalk/#comment-93</link>
		<dc:creator>EkramPrashanta</dc:creator>
		<pubDate>Thu, 08 Oct 2009 06:36:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.codechef.com/?p=121#comment-93</guid>
		<description>In ffice right now will go through this latter.&lt;br&gt;&lt;br&gt;respect&lt;br&gt;james&lt;br&gt;______________________________________________&lt;br&gt;&lt;a href=&quot;http://www.oforu.com&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;Buy Aion Kinah&lt;/a&gt; &#124; &lt;a href=&quot;http://www.eing.com&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;Cheap Aion kinah&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>In ffice right now will go through this latter.</p>
<p>respect<br />james<br />______________________________________________<br /><a href="http://www.oforu.com" target="_blank" rel="nofollow">Buy Aion Kinah</a> | <a href="http://www.eing.com" target="_blank" rel="nofollow">Cheap Aion kinah</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: EkramPrashanta</title>
		<link>http://blog.codechef.com/2009/03/17/johnny-and-the-beanstalk/#comment-1571</link>
		<dc:creator>EkramPrashanta</dc:creator>
		<pubDate>Thu, 08 Oct 2009 06:36:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.codechef.com/?p=121#comment-1571</guid>
		<description>In ffice right now will go through this latter.respectjames______________________________________________&lt;a href=&quot;http://www.oforu.com&quot; rel=&quot;nofollow&quot;&gt;Buy Aion Kinah&lt;/a&gt; &#124; &lt;a href=&quot;http://www.eing.com&quot; rel=&quot;nofollow&quot;&gt;Cheap Aion kinah&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>In ffice right now will go through this latter.respectjames______________________________________________<a href="http://www.oforu.com" rel="nofollow">Buy Aion Kinah</a> | <a href="http://www.eing.com" rel="nofollow">Cheap Aion kinah</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deepak S Patwardhan</title>
		<link>http://blog.codechef.com/2009/03/17/johnny-and-the-beanstalk/#comment-92</link>
		<dc:creator>Deepak S Patwardhan</dc:creator>
		<pubDate>Fri, 25 Sep 2009 13:26:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.codechef.com/?p=121#comment-92</guid>
		<description>I like the problem and let me rephrase it from a data structures point of view (for what its worth).&lt;br&gt;&lt;br&gt;Problem : You are given the height of a full binary tree, and a sequence of numbers, which is claimed to be the number of leaves at each level, starting from the top. You have to verify that claim is theoretically possible.&lt;br&gt;&lt;br&gt;Approach 1: Grow a tree.&lt;br&gt;Start with a single node, and grow the tree in order to satisfy the alleged number of leaves at each level, starting at top. If the claim is wrong, you&#039;ll either be unable to satisfy at a certain level (because the claim is too big), or will be left with extra leaves at the end. (claim was too small)&lt;br&gt;&lt;br&gt;Approach 2: Prune a tree. (not eco-friendly)&lt;br&gt;Given the number of leaves at the bottom of the tree, cut them to increase the number of leaves at the previous level and decrease the height of the tree. Iterate. If the claim is wrong, you&#039;ll either reach a level with odd number of leaves or end up with a zero height tree with more than one node.&lt;br&gt;&lt;br&gt;**&lt;br&gt;&lt;br&gt;Its interesting to see the the variation in runtimes, within the same language, of course. With my best efforts, I couldn&#039;t bring my runtime (14) anywhere close to the best, which is just less than 0.4.&lt;br&gt;&lt;br&gt;If I/O is the reason behind it, I guess this is my first hand experience of how slow I/O can be, if you don&#039;t take care of it.</description>
		<content:encoded><![CDATA[<p>I like the problem and let me rephrase it from a data structures point of view (for what its worth).</p>
<p>Problem : You are given the height of a full binary tree, and a sequence of numbers, which is claimed to be the number of leaves at each level, starting from the top. You have to verify that claim is theoretically possible.</p>
<p>Approach 1: Grow a tree.<br />Start with a single node, and grow the tree in order to satisfy the alleged number of leaves at each level, starting at top. If the claim is wrong, you&#39;ll either be unable to satisfy at a certain level (because the claim is too big), or will be left with extra leaves at the end. (claim was too small)</p>
<p>Approach 2: Prune a tree. (not eco-friendly)<br />Given the number of leaves at the bottom of the tree, cut them to increase the number of leaves at the previous level and decrease the height of the tree. Iterate. If the claim is wrong, you&#39;ll either reach a level with odd number of leaves or end up with a zero height tree with more than one node.</p>
<p>**</p>
<p>Its interesting to see the the variation in runtimes, within the same language, of course. With my best efforts, I couldn&#39;t bring my runtime (14) anywhere close to the best, which is just less than 0.4.</p>
<p>If I/O is the reason behind it, I guess this is my first hand experience of how slow I/O can be, if you don&#39;t take care of it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deepak S Patwardhan</title>
		<link>http://blog.codechef.com/2009/03/17/johnny-and-the-beanstalk/#comment-1570</link>
		<dc:creator>Deepak S Patwardhan</dc:creator>
		<pubDate>Fri, 25 Sep 2009 13:26:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.codechef.com/?p=121#comment-1570</guid>
		<description>I like the problem and let me rephrase it from a data structures point of view (for what its worth).Problem : You are given the height of a full binary tree, and a sequence of numbers, which is claimed to be the number of leaves at each level, starting from the top. You have to verify that claim is theoretically possible.Approach 1: Grow a tree.Start with a single node, and grow the tree in order to satisfy the alleged number of leaves at each level, starting at top. If the claim is wrong, you&#039;ll either be unable to satisfy at a certain level (because the claim is too big), or will be left with extra leaves at the end. (claim was too small)Approach 2: Prune a tree. (not eco-friendly)Given the number of leaves at the bottom of the tree, cut them to increase the number of leaves at the previous level and decrease the height of the tree. Iterate. If the claim is wrong, you&#039;ll either reach a level with odd number of leaves or end up with a zero height tree with more than one node.**Its interesting to see the the variation in runtimes, within the same language, of course. With my best efforts, I couldn&#039;t bring my runtime (14) anywhere close to the best, which is just less than 0.4.If I/O is the reason behind it, I guess this is my first hand experience of how slow I/O can be, if you don&#039;t take care of it.</description>
		<content:encoded><![CDATA[<p>I like the problem and let me rephrase it from a data structures point of view (for what its worth).Problem : You are given the height of a full binary tree, and a sequence of numbers, which is claimed to be the number of leaves at each level, starting from the top. You have to verify that claim is theoretically possible.Approach 1: Grow a tree.Start with a single node, and grow the tree in order to satisfy the alleged number of leaves at each level, starting at top. If the claim is wrong, you&#039;ll either be unable to satisfy at a certain level (because the claim is too big), or will be left with extra leaves at the end. (claim was too small)Approach 2: Prune a tree. (not eco-friendly)Given the number of leaves at the bottom of the tree, cut them to increase the number of leaves at the previous level and decrease the height of the tree. Iterate. If the claim is wrong, you&#039;ll either reach a level with odd number of leaves or end up with a zero height tree with more than one node.**Its interesting to see the the variation in runtimes, within the same language, of course. With my best efforts, I couldn&#039;t bring my runtime (14) anywhere close to the best, which is just less than 0.4.If I/O is the reason behind it, I guess this is my first hand experience of how slow I/O can be, if you don&#039;t take care of it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JensenDP</title>
		<link>http://blog.codechef.com/2009/03/17/johnny-and-the-beanstalk/#comment-91</link>
		<dc:creator>JensenDP</dc:creator>
		<pubDate>Wed, 08 Jul 2009 16:48:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.codechef.com/?p=121#comment-91</guid>
		<description>zootzoot, I don&#039;t quite understand what you mean by an &quot;input that has the highest level of a 0&quot;.  Can you give an example?</description>
		<content:encoded><![CDATA[<p>zootzoot, I don&#8217;t quite understand what you mean by an &#8220;input that has the highest level of a 0&#8243;.  Can you give an example?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JensenDP</title>
		<link>http://blog.codechef.com/2009/03/17/johnny-and-the-beanstalk/#comment-1569</link>
		<dc:creator>JensenDP</dc:creator>
		<pubDate>Wed, 08 Jul 2009 16:48:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.codechef.com/?p=121#comment-1569</guid>
		<description>zootzoot, I don&#039;t quite understand what you mean by an &quot;input that has the highest level of a 0&quot;.  Can you give an example?</description>
		<content:encoded><![CDATA[<p>zootzoot, I don&#8217;t quite understand what you mean by an &#8220;input that has the highest level of a 0&#8243;.  Can you give an example?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zootzoot</title>
		<link>http://blog.codechef.com/2009/03/17/johnny-and-the-beanstalk/#comment-90</link>
		<dc:creator>zootzoot</dc:creator>
		<pubDate>Sat, 27 Jun 2009 20:22:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.codechef.com/?p=121#comment-90</guid>
		<description>PS. You have to exclude any input that has the highest level of a 0.</description>
		<content:encoded><![CDATA[<p>PS. You have to exclude any input that has the highest level of a 0.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zootzoot</title>
		<link>http://blog.codechef.com/2009/03/17/johnny-and-the-beanstalk/#comment-1568</link>
		<dc:creator>zootzoot</dc:creator>
		<pubDate>Sat, 27 Jun 2009 20:22:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.codechef.com/?p=121#comment-1568</guid>
		<description>PS. You have to exclude any input that has the highest level of a 0.</description>
		<content:encoded><![CDATA[<p>PS. You have to exclude any input that has the highest level of a 0.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zootzoot</title>
		<link>http://blog.codechef.com/2009/03/17/johnny-and-the-beanstalk/#comment-89</link>
		<dc:creator>zootzoot</dc:creator>
		<pubDate>Sat, 27 Jun 2009 20:16:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.codechef.com/?p=121#comment-89</guid>
		<description>There is also a mathematical way of solving this problem.  If you have input with 3 levels (example 0 1 2):

level1 * 2^2 +
level2 * 2^1 +
level3 * 2^0
=
2^(num of levels - 1)

The same principle can be applied to any number of levels.

I have tested my solution for the Beanstalk problem against test data validated using the above formula, but it still says my answer is wrong?</description>
		<content:encoded><![CDATA[<p>There is also a mathematical way of solving this problem.  If you have input with 3 levels (example 0 1 2):</p>
<p>level1 * 2^2 +<br />
level2 * 2^1 +<br />
level3 * 2^0<br />
=<br />
2^(num of levels &#8211; 1)</p>
<p>The same principle can be applied to any number of levels.</p>
<p>I have tested my solution for the Beanstalk problem against test data validated using the above formula, but it still says my answer is wrong?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zootzoot</title>
		<link>http://blog.codechef.com/2009/03/17/johnny-and-the-beanstalk/#comment-1567</link>
		<dc:creator>zootzoot</dc:creator>
		<pubDate>Sat, 27 Jun 2009 20:16:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.codechef.com/?p=121#comment-1567</guid>
		<description>There is also a mathematical way of solving this problem.  If you have input with 3 levels (example 0 1 2):

level1 * 2^2 +
level2 * 2^1 +
level3 * 2^0
=
2^(num of levels - 1)

The same principle can be applied to any number of levels.

I have tested my solution for the Beanstalk problem against test data validated using the above formula, but it still says my answer is wrong?</description>
		<content:encoded><![CDATA[<p>There is also a mathematical way of solving this problem.  If you have input with 3 levels (example 0 1 2):</p>
<p>level1 * 2^2 +<br />
level2 * 2^1 +<br />
level3 * 2^0<br />
=<br />
2^(num of levels &#8211; 1)</p>
<p>The same principle can be applied to any number of levels.</p>
<p>I have tested my solution for the Beanstalk problem against test data validated using the above formula, but it still says my answer is wrong?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

