<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Recurrent Problems on Adnatull's Blog</title><link>https://adnatull.github.io/categories/recurrent-problems/</link><description>Recent content in Recurrent Problems on Adnatull's Blog</description><image><title>Adnatull's Blog</title><url>https://adnatull.github.io/images/logo.jpg</url><link>https://adnatull.github.io/images/logo.jpg</link></image><generator>Hugo</generator><language>en-us</language><lastBuildDate>Thu, 08 Feb 2018 23:08:50 +0000</lastBuildDate><atom:link href="https://adnatull.github.io/categories/recurrent-problems/index.xml" rel="self" type="application/rss+xml"/><item><title>The Josephus Problem</title><link>https://adnatull.github.io/dev/2018/02/08/the-josephus-problem/</link><pubDate>Thu, 08 Feb 2018 23:08:50 +0000</pubDate><guid>https://adnatull.github.io/dev/2018/02/08/the-josephus-problem/</guid><description>&lt;h3 id="introduction"&gt;Introduction&lt;/h3&gt;
&lt;p&gt;The &lt;strong&gt;Josephus Problem&lt;/strong&gt; is a count-out game which is regarded as a theoretical problem in Computer Science or Mathematics. In this game, &lt;strong&gt;n&lt;/strong&gt; people stand in a circle &lt;strong&gt;s&lt;/strong&gt; is the starting number of people. &lt;strong&gt;s&lt;/strong&gt; is holding a sword where &lt;strong&gt;s&lt;/strong&gt; kills &lt;strong&gt;s+k-1&lt;/strong&gt;&amp;rsquo;th people from his position and gives his sword to &lt;strong&gt;s+k&lt;/strong&gt;&amp;rsquo;th people. Thus &lt;strong&gt;s+k&lt;/strong&gt; becomes new &lt;strong&gt;s&lt;/strong&gt;.&lt;!-- more --&gt; Going in the same direction this procedure is repeated until one person is left. Remaining one person is marked as a winner.
The gif below explains the procedure. Here n = 12, k = 3 &amp;amp; s = 1.&lt;/p&gt;</description></item><item><title>How many regions do N lines divide a plane?</title><link>https://adnatull.github.io/dev/2018/01/29/how-many-regions-do-n-lines-divide-a-plane/</link><pubDate>Mon, 29 Jan 2018 23:14:15 +0000</pubDate><guid>https://adnatull.github.io/dev/2018/01/29/how-many-regions-do-n-lines-divide-a-plane/</guid><description>&lt;h3 id="explanations"&gt;Explanations:&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;N&lt;/strong&gt; straight lines are drawn on a plane paper. Each line intersects with rest all lines. That means &lt;strong&gt;N&lt;/strong&gt;&amp;rsquo;th line intersects &lt;strong&gt;N-1&lt;/strong&gt; lines. You can assume infinite number of lines can be drawn on that paper. You have to find total regions after &lt;strong&gt;N&lt;/strong&gt; lines are drawn. An image is given below to understand the problem clearly.&lt;/p&gt;
&lt;!-- more --&gt;
&lt;p&gt;&lt;img alt="The Tower of Hanoi" loading="lazy" src="https://adnatull.github.io/dev/2018/01/29/how-many-regions-do-n-lines-divide-a-plane/lines-in-plane.jpg"&gt;&lt;/p&gt;
&lt;h3 id="solve-approach"&gt;Solve Approach:&lt;/h3&gt;
&lt;p&gt;From above picture we see that base case L[0] = 1 (here, L = Lines). Whenever a line is drawn it intersects all other lines. Lets try to find the pattern from the picture. L[1] = 2, When 1st line is drawn it intersects 0 line. So, L[1] = 1+L[0] = 1. When 2&amp;rsquo;th line is drawn it intersects 1 lines. So, L[2] = 2+L[1] . Because when intersecting 1 line it creates 2 new regions. You can see for yourself by drawing on text paper. Again, when 3rd line is drawn it intersects 2 lines and creates 3 new regions. Thus, L[3] = 3+L[2].
From observation we see that, when N&amp;rsquo;th line is drawn and it intersects N-1 lines and creates N new regions. The total regions become new regions + old regions. So, for N lines, L[n] = N+L[n-1]. To know answer of L[n] we need to know L[n-1], To know L[n-1] we need to know L[n-2]&amp;hellip;.and in ending stage L[0]. Thus, we can say that recurrent solution exists for this problem.&lt;/p&gt;</description></item><item><title>The Tower of Hanoi Solution</title><link>https://adnatull.github.io/dev/2018/01/29/the-tower-of-hanoi-solution/</link><pubDate>Mon, 29 Jan 2018 16:08:41 +0000</pubDate><guid>https://adnatull.github.io/dev/2018/01/29/the-tower-of-hanoi-solution/</guid><description>&lt;h3 id="definition"&gt;Definition:&lt;/h3&gt;
&lt;p&gt;The Tower of Hanoi problem is a puzzle which can be solved by mathematically and can be implemented in programming code as well. The tower is also called &lt;strong&gt;Tower of Brahma&lt;/strong&gt; or &lt;strong&gt;Lucas&amp;rsquo; Tower&lt;/strong&gt;. In this, game there are three pegs and one one of them hold &lt;strong&gt;n&lt;/strong&gt; disks. &lt;strong&gt;n&lt;/strong&gt; disks are ordered from higher radius to lower radius from the bottom to top.&lt;/p&gt;
&lt;!-- more --&gt;
&lt;p&gt;&lt;img alt="The Tower of Hanoi" loading="lazy" src="https://adnatull.github.io/dev/2018/01/29/the-tower-of-hanoi-solution/hanoi-10ring.jpg"&gt;&lt;/p&gt;</description></item></channel></rss>