<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ajay E on Medium]]></title>
        <description><![CDATA[Stories by Ajay E on Medium]]></description>
        <link>https://medium.com/@ajay.anzero?source=rss-f80478cebe9c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*oSLsJKjZorBWIi6REGLg8g.jpeg</url>
            <title>Stories by Ajay E on Medium</title>
            <link>https://medium.com/@ajay.anzero?source=rss-f80478cebe9c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 10:36:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ajay.anzero/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Day 006 of learning DSA]]></title>
            <link>https://medium.com/@ajay.anzero/day-006-of-learning-dsa-b5bb2d322ad6?source=rss-f80478cebe9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/b5bb2d322ad6</guid>
            <category><![CDATA[math]]></category>
            <category><![CDATA[dsa-problem]]></category>
            <category><![CDATA[sad]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Ajay E]]></dc:creator>
            <pubDate>Mon, 15 Dec 2025 13:26:31 GMT</pubDate>
            <atom:updated>2025-12-15T13:26:31.928Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Hi there I am Ajay E. This blog is to share my journey of learning DSA.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4W9agSY9N8hLk4_gZ3Gylg.png" /></figure><h4>Problem:</h4><p>You are given a <strong>cubic dice</strong> with <strong>6</strong> faces. All the individual faces have a number printed on them. The numbers are in the range of <strong>1 to 6</strong>, like any ordinary dice. You will be provided with a face of this cube, your task is to guess the number on the opposite face of the cube.</p><p><strong>Example:</strong></p><p>input: n = 6</p><p>output: 1</p><p>input: n = 5</p><p>output: 2</p><h4>Naive solution:</h4><p>In a normal 6-faced dice, 1 is opposite to 6, 2 is opposite to 5, and 3 is opposite to 4. Hence a normal if-else-if block can be placed</p><p>Time complexity: O(1)</p><p>Space complexity: O(1)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mG9KDaweaCXoh7ijP02z7A.png" /></figure><p><strong>Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c0Z0_DyncaTFouYuBNKL8g.png" /></figure><h4>Best solution:</h4><p>The sum of two opposite side of the dice is 7. So, we just need to sub the given number with 7 and we got the answer. opp = 7-n</p><p>Time complexity: O(1)</p><p>Space complexity: O(1)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iWtUobSGPJSEGGbibfkOcQ.png" /></figure><p><strong>Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NndFGIHXCO47BrYinbeUHg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5bb2d322ad6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 005 of learning DSA]]></title>
            <link>https://medium.com/@ajay.anzero/day-005-of-learning-dsa-39cfb3ee50fd?source=rss-f80478cebe9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/39cfb3ee50fd</guid>
            <category><![CDATA[sad]]></category>
            <category><![CDATA[dsa-problem]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[problems]]></category>
            <category><![CDATA[bitwise]]></category>
            <dc:creator><![CDATA[Ajay E]]></dc:creator>
            <pubDate>Mon, 15 Dec 2025 00:46:44 GMT</pubDate>
            <atom:updated>2025-12-15T00:46:44.440Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Hi there I am Ajay E. This blog is to share my journey of learning DSA.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cAJx3hcu3mLqeEiFQ5ixDg.png" /></figure><h4>Problem:</h4><p>Given two numbers <strong>a</strong> and <strong>b</strong>, the task is to swap them.</p><p><strong>Example:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Djkh0PUW41uYKnbUkORaOA.png" /></figure><h4>Naive solution:</h4><p>The idea is to use a third variable, say <strong>temp</strong> to store the original value of one of the variables during the swap.</p><ul><li>Store the value of <strong>a </strong>in <strong>temp</strong>.</li><li>Assign the value of <strong>b </strong>to <strong>a</strong>.</li><li>Assign the value of <strong>temp </strong>to <strong>b</strong>.</li></ul><p>Time complexity: O(1)</p><p>Space complexity: O(1)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3PYyaMDyWB8DyoliV1yj4Q.png" /></figure><p><strong>Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FI1TdYMsesLqaRjz6TM5Hg.png" /></figure><h4>Alternative solution:</h4><p>We can also swap using built-in functionalities like<strong> swap() </strong>function in C++, <strong>tuple unpacking </strong>in Python, <strong>destructuring assignment </strong>in JavaScript.</p><p>Time complexity: O(1)</p><p>Space complexity: O(1)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m4CET8B5QY90caDZnhd4Vg.png" /></figure><p><strong>Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*10Gb3vQ9JRIM4O1TdEkGqA.png" /></figure><h4>Best solutions:</h4><p>Here there is two best solutions.</p><ol><li>Using Arithmetic operator.</li><li>Using Bitwise XOR.</li></ol><p><strong>Using Arithmetic operator:</strong></p><ul><li>Store the sum of <strong>a </strong>and <strong>b </strong>in <strong>a </strong>(a = a + b).</li><li>Get the original value of <strong>a</strong>, that is (sum — original value of b)and store it in <strong>b </strong>(b = a — b).</li><li>Get the original value of <strong>b</strong>, that is (sum — original value of a)and store it in <strong>a </strong>(a = a — b).</li></ul><p>Time complexity: O(1)</p><p>Space complexity: O(1)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kDgXEJ-L0KdUdMuyXK6kpA.png" /></figure><p><strong>Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rsqxgTuk6af7_1g5tztP6A.png" /></figure><p><strong>Using Bitwise XOR:</strong></p><p>The idea is to use the properties of XOR to swap the two variables.</p><ul><li><strong>a = a ^ b:</strong> Store the Bitwise XOR of <strong>a</strong> and <strong>b</strong> in <strong>a</strong>. Now, <strong>a </strong>holds the result of <strong>(a ^ b)</strong>.</li><li><strong>b = a ^ b:</strong> Bitwise XOR the new value of <strong>a </strong>with <strong>b </strong>to get the original value of <strong>a</strong>. This gives us, b = (a ^ b) ^ b = a.</li><li><strong>a = a ^ b:</strong> Bitwise XOR the new value of <strong>a </strong>with the new value of <strong>b</strong> (which is the original <strong>a</strong>) to get the original value of <strong>b</strong>. This gives us, a = (a ^ b) ^ a = b.</li></ul><p>Time complexity: O(1)</p><p>Space complexity: O(1)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7FBLi7t-Ocn_-nlH9AbYig.png" /></figure><p><strong>Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VQdx-4wUzMPZp55CHT2iAg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39cfb3ee50fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 004 of learning DSA]]></title>
            <link>https://medium.com/@ajay.anzero/day-004-of-learning-dsa-e2d53a0bc3e3?source=rss-f80478cebe9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2d53a0bc3e3</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[overflow]]></category>
            <category><![CDATA[sad]]></category>
            <category><![CDATA[math]]></category>
            <category><![CDATA[dsa-problem]]></category>
            <dc:creator><![CDATA[Ajay E]]></dc:creator>
            <pubDate>Sat, 13 Dec 2025 12:27:57 GMT</pubDate>
            <atom:updated>2025-12-13T12:27:57.232Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Hi there I am Ajay E. This blog is to share my journey of learning DSA.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nL7tMlb-yxYh5Ws4ffYETw.png" /></figure><h4><strong>Problem:</strong></h4><p>Get a input form the user n and we have to find the sum of squares of first n natural numbers.</p><p><strong>Example:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t1dCDjK0kxHI82FEka_L3Q.png" /></figure><h4>Naive solution:</h4><p>By seeing this we are thinking to use loop iteration and recursion. By looping from 1 to n and made i² in each iteration and add it to sum.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YLkou45apWt3KMKihlSfcg.png" /></figure><p><strong>Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fEqvObBu4S5J6bbwyZoYwA.png" /></figure><h4>Best solution:</h4><p>The idea for this approach is to use the mathematical formulae for the sum of squares of first n natural numbers.</p><blockquote><em>We can prove this formula using induction. We can easily see that the formula is true for n = 1 and n = 2 as sums are 1 and 5 respectively.</em></blockquote><blockquote><em>Let it be true for n = k-1. So sum of k-1 numbers<br>is (k — 1) * k * (2 * k — 1)) / 6</em></blockquote><blockquote><em>In the following steps, we show that it is true <br>for k assuming that it is true for k-1.</em></blockquote><blockquote><em>Sum of k numbers = Sum of k-1 numbers + k2<br> = (k — 1) * k * (2 * k — 1) / 6 + k2<br> = ((k2 — k) * (2*k — 1) + 6k2)/6<br> = (2k3–2k2 — k2 + k + 6k2)/6<br> = (2k3 + 3k2 + k)/6<br> = k * (k + 1) * (2*k + 1) / 6</em></blockquote><p><strong>Example : </strong>Find sum of squares of the first 3 natural numbers<br><strong>Solution: </strong><br> = 3 * (3 + 1) * (2*3 + 1) / 6<br> = (3 * 4 * 7) / 6<br> = 84 / 6<br> = 14</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1yoLC-MfZ4d2OVXxAWmDyw.png" /></figure><p><strong>Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D28x8ytm19ou9EAhd1ywCA.png" /></figure><p><strong>Avoiding the overflow:</strong></p><p><strong>The Concept</strong></p><p>Imagine your computer variable is a <strong>Car Odometer</strong> that only has 4 digits. The maximum number it can show is <strong>9999</strong>.</p><p><strong>The Scenario</strong></p><p>You are driving, and the odometer reads <strong>9999</strong>. You drive <strong>1</strong> more mile.</p><ul><li><strong>Math says:</strong> 9999+1=10,000</li><li><strong>The Odometer says:</strong> <strong>0000</strong></li></ul><p><strong>What Happened?</strong></p><p>The number <strong>10,000</strong> was too big to fit in the 4-digit display. The “1” at the front fell off (spilled over), and only the zeros remained.</p><p><strong>Why does it turn Negative in Code?</strong></p><p>Computers use the first bit (digit) to decide if a number is positive or negative. When an integer overflows, it accidentally flips that specific bit. The computer sees this flip and suddenly thinks your massive positive number is now a massive <strong>negative</strong> number.</p><p><strong>In short:</strong> Overflow is when a number gets too big for its box, so it “rolls over” and becomes garbage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PAVVuKSUWDpJi0buTr9XTA.png" /></figure><p><strong>Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qCFMhlach5duasoLPwd8hw.png" /></figure><p><strong>Why we divide n*(n+1)/2 and the (2n+1)/3:</strong></p><p>n*(n+1) divides by 2 early to keep the intermediate numbers small, preventing them from growing too large and exceeding the computer’s limit (integer overflow).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2d53a0bc3e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 003 of learning DSA]]></title>
            <link>https://medium.com/@ajay.anzero/day-003-of-learning-dsa-fb0c33f17892?source=rss-f80478cebe9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb0c33f17892</guid>
            <category><![CDATA[iteration]]></category>
            <category><![CDATA[math]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[dsa-problem]]></category>
            <category><![CDATA[sad]]></category>
            <dc:creator><![CDATA[Ajay E]]></dc:creator>
            <pubDate>Sat, 13 Dec 2025 12:26:18 GMT</pubDate>
            <atom:updated>2025-12-13T12:26:18.398Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Hi there I am Ajay E. This blog is to share my journey of learning DSA.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ykWBEx8zRIl50llIn9qHww.png" /></figure><h4>Problem:</h4><p>Get a input n from the user and calculate sum of n natural numbers.</p><p><strong>Example:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PWxqhdapree_q-gos65unA.png" /></figure><h4>Naive solution:</h4><p>By seeing this problem everyone got answer that is by using loop. We iterate to n times add the number to sum in each iteration.</p><p>Time complexity: O(n)</p><p>Space complexity: O(1)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hcX-AOj6AUMfCluNK93qgg.png" /></figure><p><strong>Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*adi4OysuTMEPBNIirpoSLw.png" /></figure><h4>Alternative solution:</h4><p>In this solution we gonna use recursion method (looping of a function).</p><p>Time complexity: O(n)</p><p>Space complexity: O(n)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9R_FPkwDIjV92CVEiT4I9g.png" /></figure><p><strong>Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OHzrmasU1xeiw_hsYdH2xQ.png" /></figure><p>Best solution:</p><p>I have studied TN State Board from Tamil Nadu, India. In my class 10 I have learned some math formula to calculate sum of n numbers, which is n*(n+1)/2. We gonna use that formula.</p><p>Time complexity: O(1)</p><p>Space complexity: O(1)</p><blockquote><strong><em>We can prove this formula using induction.</em></strong><em><br>It is true for n = 1 and n = any number.<br>For n = 1, sum = 1 * (1 + 1)/2 = 1<br>For n = 4, sum = 4* (4 + 1)/2 = 10<br>Let it be true for k = n-1.<br>Sum of k numbers = (k * (k+1))/2<br>Putting k = n-1, we get<br>Sum of k numbers = ((n-1) * (n-1+1))/2<br> = (n — 1) * n / 2<br>If we add n, we get,<br>Sum of n numbers = n + (n — 1) * n / 2<br> = (2n + n2 — n)/2<br> = n * (n + 1)/2</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-AtwnzCzbb8JTAX2IDyPFg.png" /></figure><p><strong>Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pWEp_tC3-K1w9l8zx6sS3w.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb0c33f17892" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 002 of learning DSA]]></title>
            <link>https://medium.com/@ajay.anzero/day-002-of-learning-dsa-55f84371dc8b?source=rss-f80478cebe9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/55f84371dc8b</guid>
            <category><![CDATA[loop]]></category>
            <category><![CDATA[recursion]]></category>
            <category><![CDATA[sad]]></category>
            <category><![CDATA[iteration]]></category>
            <category><![CDATA[dsa-problem]]></category>
            <dc:creator><![CDATA[Ajay E]]></dc:creator>
            <pubDate>Fri, 12 Dec 2025 11:32:32 GMT</pubDate>
            <atom:updated>2025-12-12T11:37:58.225Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Hi there I am Ajay E. This blog is to share my journey of learning DSA.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jx5AUdh1VmG47JSOL9Lyjg.png" /></figure><h4>Problem:</h4><p>Get a number and multiplication number form the user and print multiplication table using it.</p><p><strong>Example:</strong></p><figure><img alt="example" src="https://cdn-images-1.medium.com/max/1024/1*7wLr5kliTUf0JRZCSbWnUg.png" /></figure><h4>Iteration solution:</h4><p>We know that iteration means loop. So we are using loop to solve this. In this method, you begin with the number whose table you want to print and use a loop to multiply it with increasing values.</p><p>Time complexity: O(1)</p><p>Space complexity: O(1)</p><figure><img alt="iteration" src="https://cdn-images-1.medium.com/max/1024/1*dSAz7cP5BrbmGl_Rx7F3GQ.png" /></figure><p><strong>Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7SGol5n9ghJZ-vH3CHlxcA.png" /></figure><h4>Illustration:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8DN7aK-3lzqMhZSEzk6YbA.png" /></figure><h4>Recursive solution:</h4><p>recursion means looping of a function. So we are looping the printTable function here. We stop the recursion when i becomes greater than num as we need to print only given no of lines .</p><p>Time complexity: O(1)</p><p>Space complexity: O(1)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UAvUYFC1v4bO8kSwVq22lA.png" /></figure><p><strong>Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TIJhBY8C_F8mkriNLN3RwA.png" /></figure><p><strong>Illustration:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vE1Q6ZYvdR-pTlYOvHpaWg.png" /></figure><p>In the above two solution they did same thing which is loop. So you think two are the best solution but iteration is better than recursion.</p><p>Iteration is better because it saves memory and won&#39;t crash your program when dealing with large numbers, whereas recursion can easily run out of memory (stack overflow).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55f84371dc8b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 001 of learning DSA.]]></title>
            <link>https://medium.com/@ajay.anzero/day-001-of-learning-dsa-cbe50857db34?source=rss-f80478cebe9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/cbe50857db34</guid>
            <category><![CDATA[dsa-problem]]></category>
            <category><![CDATA[sad]]></category>
            <category><![CDATA[even-or-odd]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Ajay E]]></dc:creator>
            <pubDate>Fri, 12 Dec 2025 10:13:09 GMT</pubDate>
            <atom:updated>2025-12-12T10:27:57.341Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Hi there I am Ajay E. This is the blog to share my learning journey about DSA.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*otF8JmFkoXZsT1dAX_l4_g.png" /></figure><h3>Check Even or Odd:</h3><p>Get a number from user and check whether it is Even or Odd, return Odd or Even.</p><p><strong>Example:</strong></p><p>Case 1:</p><p>input: n=15</p><p>output: Odd</p><p>Case 2:</p><p>input: n=6</p><p>output: Even</p><blockquote>By seeing this problem, every one of us knows answer i.e, when the number divide by 2 and gives reminder of 0 it is Even else it is Odd by using modulus operator (%). We know that right ? But it is naive solution.</blockquote><h4>Naive solution:</h4><p>When we divide the given number with 2, if the reminder is 0 it is even else it is odd.</p><p><em>Time complexity: O(1)</em></p><p><em>Space complexity: O(1)</em></p><h4>Program:</h4><figure><img alt="naive-solution" src="https://cdn-images-1.medium.com/max/1024/1*eIz81ZKCUpP7o52zrmir5Q.png" /></figure><p><strong>Output:</strong></p><figure><img alt="output-1" src="https://cdn-images-1.medium.com/max/1024/1*cNiYpFyIsNSzLqlQD83QIQ.png" /></figure><figure><img alt="output-2" src="https://cdn-images-1.medium.com/max/1024/1*KGmKpI_s-KqE5JLOCeeFMw.png" /></figure><p>This code is works but we need best solution.</p><h4>Best solution:</h4><p>When we convert the given number to binary number we can identify that every odd number ends with 1 I mean last digit and every even number ends with 0 I mean last digit. How can we use this thing program. By using bitwise AND (&amp;). When we perform bitwise AND with the given number and 1, if we get 0 the number is even else the number is odd.</p><p>Time complexity: O(1)</p><p>Space complexity: O(1)</p><h4>Example:</h4><figure><img alt="example" src="https://cdn-images-1.medium.com/max/1024/1*dI-xVz1Lu0ngwTiPxsUMqA.png" /></figure><h4>Program:</h4><figure><img alt="best-solution" src="https://cdn-images-1.medium.com/max/1024/1*UHJGnbROF0Lj7xf5dWpKTg.png" /></figure><p><strong>Output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sVYrRrFfoktHyehwJcSw4g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eAm1sGdLVdO2I_kSX77BWg.png" /></figure><p>This is the best solution, because it works on binary data which is faster and effective.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cbe50857db34" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Demonstration of a Simple Electrical Circuit]]></title>
            <link>https://medium.com/@ajay.anzero/experiment-title-demonstration-of-a-simple-electrical-circuit-13cc65f12e52?source=rss-f80478cebe9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/13cc65f12e52</guid>
            <category><![CDATA[electronics]]></category>
            <category><![CDATA[wiring]]></category>
            <category><![CDATA[ece]]></category>
            <category><![CDATA[switchboard-wiring]]></category>
            <category><![CDATA[switchboard]]></category>
            <dc:creator><![CDATA[Ajay E]]></dc:creator>
            <pubDate>Mon, 03 Nov 2025 11:53:39 GMT</pubDate>
            <atom:updated>2025-11-03T15:29:13.616Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone, I am Ajay. I am writing this article to share my knowledge about “Demonstration of a Simple Electrical Circuit” which was taught by my faculty during my study (Electronics and Communication Engineering-ECE).</p><p>The main objective of this article is to connect and demonstrate a simple electrical circuit consisting of a 💡 bulb, 🌬️ fan, 🔘 switch, and 🔌 socket using a switchboard and standard wiring accessories.</p><p>The main accessories required to do this project is,</p><ol><li>Bulb with holder (1) — 60W, 230V AC or safe 12V lab bulb if using step-down voltage.</li><li>Fan(Table/Ceiling/Small)(1) — 20V AC or 12V DC fan for low-voltage lab demo.</li><li>5-pin socket outlet(1) — 5A, 230V.</li><li>Switches(3) — 5A, 230V.</li><li>Switchboard(Wood/Plastic)(1) — With spaces for mountin accessories.</li><li>Wires(PVC insulated)(As required) — Phase (RED/BROWN), Neutral (BLACK/BLUE), Earth (GREEN/YELLOW-GREEN).</li><li>Fuse or MCB(1) — 5A(For protection).</li><li>Tools(1 set) — Screwdriver set, wire stripper, plier, tester.</li><li>Insulation tape(1).</li></ol><h4>SWITCH:</h4><p>A switch is used to make or break an electrical circuit. It is used switch ‘ON’ or ‘OFF’ the supply of electricity to the appliances.</p><p>There are various switches such as,</p><ol><li>Surface switch.</li><li>Flush switch.</li><li>Ceiling switch.</li><li>Pull switch.</li><li>Push button switch.</li><li>Bed switch.</li></ol><p>(i). <strong>Surface switch</strong> — It is mounted on wooden boards fixed on the surface of a wall. It is of three types,</p><p>&gt; One-way switch.</p><p>&gt; Two-way switch.</p><p>&gt; Intermediate switch.</p><blockquote><strong>One-way switch:</strong> It is used to control single circuits and lamp (Fig. 1).</blockquote><blockquote><strong>Two-way switch:</strong> It is used to divert the flow of current to either of two directions. The two-wayswitch can also be used to control one lamp from two different places as in the case of staircasewiring (Fig.2).</blockquote><blockquote><strong>Intermediate switch:</strong> It is used to control a lamp from more than two locations (Fig.3). o (i) Flush switch: It used for decorative purpose (Fig 4). o (ii) Bed switch: As the name indicates, it is used to switch ‘on’ the light from any place, other than switch board or from near the bed. This switch is connected through a flexible wire (Fig.5).</blockquote><figure><img alt="Types of surface switch" src="https://cdn-images-1.medium.com/max/1024/1*RcTChUSqGXBCcZVsWjIIAw.png" /></figure><h4>FUSE:</h4><p>An fuse is an electric / electronic or mechanical device, which is used to protect circuits from over current, overload and ensure the protection of the circuit. Electric fuse was invented by Thomas Alva Edison in 1890.There are many types of fuses, but the function of all these fuses is the same. In this article, we will discuss the different types of fuses, its construction, working and operation and their application in various electronics and electrical systems. The different symbols of fuse are given below,</p><figure><img alt="Symbol of fuse" src="https://cdn-images-1.medium.com/max/1024/1*wsMwjW_NWpmwSwoNDB_O0Q.png" /></figure><h4><strong>Construction and working of fuse:</strong></h4><p>A general Fuse consists of a low resistance metallic wire enclosed in a non combustible material. It is used to connect and install in series with a circuit and device which needs to be protected from short circuit and overcurrent. Otherwise, electrical appliance may be damaged in case of absence of the fuse and circuit breaker as they are unable to handle the excessive current according to their rating limits.</p><p>The <strong>working principle of a fuse</strong> is based on the “<strong>Heating effect of Current</strong>” i.e. Whenever a short circuit, over current or mismatched load connection occurs, then the thin wire inside the fuse melts because of the heat generated by the heavy current flowing through it. Therefore, it disconnects the power supply from the connected system. In normal operation of the circuit, fuse wire is just a very low resistance component and does not affect the normal operation of the system connected to the power supply.</p><h4><strong>How to select proper rating size of fuse?</strong></h4><p>While selecting the proper fuse and its rated size for electrical appliances is based on different factors and environments. But the following basic formula shows <strong>how to choose the right size of fuse?</strong></p><h3>Fuse Rating = ( Power / Voltage ) x 1.25</h3><p><strong>For example</strong>, you have to find the right size of fuse for 10A two pin socket. (1000W / 230V ) x 1.25 = <strong>5.4A </strong>In the above example, 1kW is the power rating which can be controlled through the 2 pin socket and the main supply voltage is single phase 230V AC (120V AC in US).</p><h4><strong>Types of fuses,</strong></h4><p>There are different types of fuses available in the market and they can be categories on the basis of different aspects. Fuses can be divided into two main categories according to the type of input supply voltage.</p><p>(i) AC fuses.</p><p>(i)DC fuses.</p><p>There is a little difference between AC and DC fuses used in the AC and DC Systems which has been discussed below.</p><h4><strong>Uses and Applications of Fuses Different types of Electrical and Electronic Fuses can be used in all types of electrical and electronic systems and applications including:</strong></h4><p>(i) Motors &amp; Transformers.</p><p>(ii) Air-conditions.</p><p>(iii) Home distribution boards.</p><p>(iv) General electrical appliances and devices.</p><p>(v) Laptops.</p><p>(vi) Cell phones.</p><p>(vii) Game systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4WFSIleMERB9OOq13kVhew.png" /></figure><h4>INDICATOR:</h4><p>A indicator is a device which provides visual or remote indication of a fault on the electric power system. Also called a faulted circuit indicator (FCI), the device is used in electric power distribution networks as a means of automatically detecting and identifying faults to reduce outage time. Overhead indicators are used to visualize the occurrence of an electrical fault on an overhead electrical system. Underground indicators locate faults on an underground system. Often these devices are located in an underground vault. Some fault indicators communicate back to a central location using radio or cellular signals. Indicator lights are a type of illuminating device that is commonly used to signify that equipment is either receiving power or that there is some form of malfunction. We have all seen the red light come on when you power ON a device. That is an example of an indicator light. They serve a very basic but very important function, especially when it comes to indicating some type of malfunction. These indicator lights are designed for panel usage but that does not mean that they cannot be installed in another location.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eZNglnsRQpBCF0Dai65PEw.png" /></figure><p>The Power Function Indicator Light identifies the proper operation of electrical equipment that provides no audible, visible or vibratory indication of operation. The two-light indicator senses both a connection to an electrical supply source and any consumption of electrical current which indicates operation. The function of an indicator switch is to light the LED 1 when RF at Port C-1 is closed and to light the LED 2 when RF at Port C-2 is closed. The indicator also can be used as a data transmitter from computer or other equipment.</p><p>There are three kinds of indicator words: position indicators, reason indicators, and objection indicators.</p><h4>LAMPS:</h4><p>Electric lamp is a conventional light emitting component used in different circuits, mainly for lighting and indicating purposes. The construction of lamp is quite simple, it has one filament surrounding which, a transparent glass made spherical cover is provided. The filament of the lamp is mainly made of tungsten as it has high melting point temperature. A lamp emits light energy as the thin small tungsten filament of lamp glows without being melted, while current flows through it.</p><h4><strong>What is an electrical lamp?</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*gARxHTjwuQ9DvDwYG2NHFw.png" /></figure><h4><strong>Uses of electric lamps:</strong></h4><p>These lamps are mainly get used for lighting and indicating purpose. Although, now a days use of light emitting diodes LEDs for these two purposes dominates uses of conventional lamps. But still they are in use although at maximum places they are replaced by LEDs.</p><h4><strong>Rating of electric lamps:</strong></h4><p>There are mainly three things that must be known before selecting a lamp for a specific purpose.</p><ol><li>Voltage across which the lamp to be connected for getting normal brightness of light. This voltage rating of electric lamp must be marked on the lamps. If the supply of voltage across the lamp is lower than rated value, the lamp will not glow properly as current flowing through it will be insufficient. Again if the voltage across the lamp crosses the rated value, the filament may not be able to sustain the over current and it will blow out.</li><li><strong>Power Rating or Current Rating of Electric Lamp:</strong> When an electric lamp is connected across its rated voltage, its filament will carry current depending upon the electrical resistance offered by the lamp. The filament of the lamp is so designed, that it must give most optimized brightness for that current. This current rating of electric lamp is very important parameter, as it determines the power consumption of the lamp. As a filament of lamp is considered as 100% resistive, the power consumption is nothing but the product of voltage and current rating of the lamp. Consumption of power is nothing but power rating of the lamp. Hence, if voltage rating of a lamp is known to us, then it is enough to know either current rating or power rating of that lamp, as power rating can be calculated from current rating and current rating can be calculated from power rating since electric power is product of voltage and current. It is normal practice that small rated lamps are rated by current and higher rated electric lamps are rated by power.</li></ol><h4><strong>Types of electric lamps:</strong></h4><p>Another thing must be considered during selecting a lamp for a circuit. What types of an electric lamp is suitable for specific circuits? Types of lamp depend upon designing pattern of the lamps. According to variation of designs, there are varieties of types lamps are listed below,</p><h4><strong>1. Edison Screw type lamp:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/323/1*03sSAa6tFZ8lC9Ii4TVaOQ.png" /></figure><p>The main feature of this type of lamp is that it has one contact in the base and other contact on the metallic body of the lamp. This metallic body of the lamp is of screw shaped. Commonly two types of Edison Screw lamps are available in market,</p><p>i. Miniature Edison Screw Lamp (MES) its bulb diameter is 10 mm (approx).</p><p>ii. 2. Lilliput Edison Screw Lamp (LES) its bulb diameter is 5 mm (approx).</p><h4>(i). <strong>Miniature Center Contact type Lamps:</strong></h4><p>Like MES and LES, it has one contact in the base and other contact on the metallic body of the lamp. But main difference is that this metallic body of the lamp is not screw shaped-it has bayonet style fittings. Its bulb diameter is 10 mm (approx).</p><h4>(ii). <strong>Small Bayonet Cap Lamps:</strong></h4><p>It has also bayonet style fitting but has both contacts on the base of the lamp, hence there is no electrical connection with the body of the lamp. The standard bulb diameter is about 40 mm. It may have horizontal as well as vertical filament arrangements as shown. The power rating of the bulb can be up to 24 watt.</p><h4>(iii).<strong> Wire Ended Lamps:</strong></h4><p>These are very small size lamps of about 6 mm long and has 3 mm diameter. The design is very simple; here contact wires directly come out from the glass cashing. Wire ended lamps are mainly designed for very low power rating and are also available in the market in very cheap rate. This lamp does not need any lamp holder; it can be soldered directly to the circuit board with the help of the contact wires coming out from the glass cashing.</p><h3>BASIC SWITCH BOARD WIRING WITH LAMP, FAN &amp; 5PIN SOCKET</h3><ol><li>63A Fuse(1 PCs).</li><li>230V Indicator(1 PCs).</li><li>Single Pole(SP) Switch(3 PCs).</li><li>230V Electronic fan Regulator(1PCs).</li><li>32A 5-Pin Socket(1 PCs).</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rFiVP4TU6l4upTgBx1f-PQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wEpCsYnnsrOwUzOkGV9xgQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Dzo84q6Rof3qzPP4O6T1w.jpeg" /></figure><h4><strong>Procedure:</strong></h4><p>1. Connect the phase of the main power source to any one of the terminals of the fuse.</p><p>2. Connect any one of the terminals of each switch together, then connect them to the fuse.</p><p>3. Connect the neutral wire to the 5-pin socket.</p><p>4. Connect the other end of the first switch to the 5-pin socket.</p><p>5. Connect the other end of the second switch to the light bulb, and also connect the other end of the last switch to one end of the regulator.</p><p>6. Connect the other end of the regulator to the fan.</p><p>7. Finally, connect the neutral wire to both the bulb and the fan.</p><h4><strong>Components used to make the switch board:</strong></h4><h4>1. Fuse:</h4><p>In the above wiring diagram, we have connected a 63A fuse in series with the main input phase supply. In this diagram, the total load of the circuit is 56A(calculated by the total of all switches ratings). So 63A is enough for this switch board. But don’t use the fuse having a current rating of less than 56A.</p><h4>2. <strong>Switch:</strong></h4><p>Here we use 32A Switch used for the 32A Socket which can be used to connect any high current equipment such as Mixer, Heater, Induction Cooker, etc.</p><h4>3.<strong> Socket:</strong></h4><p>Here we use 32A Socket. Because it support Mixer, Heater, Induction Cooker, etc.</p><h4>4. <strong>Indicator:</strong></h4><p>Here we have connected a red color indication lamp. This lamp is rated at 230V AC. It helps to know if the power supply on the board is available or not. The indication lamp is connected just after the fuse, so if the fuse burned due to any fault then also it will show that the power supply is not available on the board. The indication lamp can be connected before the fuse also but if the fuse burned then also it will glow.</p><h4>5.<strong> Electrical fan Regulator:</strong></h4><p>Here we have used a 230V electronic fan regulator to control the speed of the fan. The fan regulator is connected between the fan and the switch. The switch provides the function to ON or OFF the fan whereas the fan regulator provides the function of speed control.</p><h4>OBSERVATION TABLE:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*opz3_WIzT7DXrIZ5cxQ0ew.png" /></figure><p>Finally, A simple electrical circuit with a bulb, fan, switch, and socket was successfully connected using a switchboard and wiring accessories.</p><h4>Common questions raised in this experiment:</h4><ol><li><strong>Why is the phase connected through the switch instead of the neutral?</strong></li></ol><p>(i). The phase wire carries the live current.</p><p>(ii). When we connect the switch to the phase line, turning it OFF disconnects the live current from the appliance — making it safe to touch or repair.</p><p>(iii) If the neutral were switched instead, the appliance would still be live even though it appears “OFF”, which is dangerous.</p><p>2.<strong> What is the function of the earth connection in a socket?</strong></p><p>(i). The earth (ground) wire provides a safe path for leakage current to flow into the ground.</p><p>(ii). It protects users from electric shock if any metal part of the appliance accidentally becomes live.</p><p>(iii) In short, it ensures safety by preventing electric shock and equipment damage.</p><p>3. <strong>Why is a fuse/MCB always connected in the phase line?</strong></p><p>(i). A fuse or MCB (Miniature Circuit Breaker) is designed to disconnect the live current when there’s a fault or overload.</p><p>(ii). If connected to the neutral, the circuit might look disconnected but the live current still flows — posing a shock hazard.</p><p>(iii). Hence, it’s always connected in the phase to safely cut off power during faults.</p><p>4. <strong>How does a fan regulator control the speed of the fan?</strong></p><p>(i). A fan regulator controls the voltage supplied to the fan motor.</p><h4>Lower voltage → less current → slower fan speed.</h4><h4>Higher voltage → high current → higher fan speed.</h4><p>(ii). Older regulators use resistances to drop voltage, while modern electronic ones use triacs or capacitors to control speed efficiently with less power loss.</p><p>5. <strong>What safety precautions should be followed during domestic wiring?</strong></p><p>(i). Always switch off the main supply before working.</p><p>(ii). Use properly rated wires and fuses.</p><p>(iii). Follow color coding (red/brown = phase, black/blue = neutral, green = earth).</p><p>(iv). Avoid loose connections and overloading circuits.</p><p>(v). Keep wires insulated and away from water.</p><p>(vi). Use earthing for all metallic appliances.</p><p>6. <strong>Explain the difference between series and parallel connection of loads.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*CZQj0CHmN45uac-r0KfDCA.png" /></figure><p>7. <strong>Why should color-coded wires be used in wiring?</strong></p><p>(i). Color codes help in identifying each wire easily:</p><p><strong>Red/Brown → Phase (Live)</strong></p><p><strong>Black/Blue → Neutral</strong></p><p><strong>Green/Yellow-green → Earth</strong></p><p>(ii). This prevents wiring mistakes, ensures safety, and helps maintenance or repairs to be done correctly and quickly.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13cc65f12e52" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>