<?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 Rajat Jadam on Medium]]></title>
        <description><![CDATA[Stories by Rajat Jadam on Medium]]></description>
        <link>https://medium.com/@rjtjdm?source=rss-1c2322dc392b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Alj0vWp3-wID0rYWnZOYQw.jpeg</url>
            <title>Stories by Rajat Jadam on Medium</title>
            <link>https://medium.com/@rjtjdm?source=rss-1c2322dc392b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 21:36:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rjtjdm/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[Ugly Number]]></title>
            <link>https://rjtjdm.medium.com/ugly-number-7c85f94bf90f?source=rss-1c2322dc392b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c85f94bf90f</guid>
            <category><![CDATA[memorization]]></category>
            <category><![CDATA[dynamic-programming]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[cpp]]></category>
            <category><![CDATA[ugly-number]]></category>
            <dc:creator><![CDATA[Rajat Jadam]]></dc:creator>
            <pubDate>Wed, 20 May 2020 08:46:37 GMT</pubDate>
            <atom:updated>2020-05-20T08:46:37.001Z</atom:updated>
            <content:encoded><![CDATA[<p>An ugly number is a number which is divisible by 2, 3, or 5 only.</p><p>Here is my dynamic programming approach to solve the problem.</p><blockquote>#include &lt;iostream&gt;<br>#include&lt;math.h&gt;<br>#include&lt;vector&gt;<br>#include&lt;stack&gt;<br>#include&lt;queue&gt;<br>#include&lt;bits/stdc++.h&gt;<br>#include&lt;limits.h&gt;<br>using namespace std;<br>int calmin(int a,int b){<br> if(a&lt;b){<br> return a;<br> }<br> else{<br> return b;<br> }<br>}<br>void ProduceArray(vector&lt;int&gt; &amp;x,int max){<br> //cout&lt;&lt;”Inside Produce”&lt;&lt;max;<br> x[0]=0;<br> x[1]=1;<br> int i=2;<br> int n2=1;<br> int n3=1;<br> int n5=1;<br> while(i&lt;=max){<br> //cout&lt;&lt;”\n”&lt;&lt;”Working”;<br> int a=2*x[n2];<br> int b=3*x[n3];<br> int c=5*x[n5];<br> int min=calmin(a,calmin(b,c));<br> x[i]=min; <br> if(min==a){<br> n2++;<br> }<br> if(min==b){<br> n3++;<br> }<br> if(min==c){<br> n5++;<br> }<br> i++;<br> }<br> <br>}<br>int main() {<br> int TestCase;<br> cin&gt;&gt;TestCase;<br> int max=INT_MIN;<br> int A[TestCase];<br> for(int i=0;i&lt;TestCase;i++){<br> cin&gt;&gt;A[i];<br> if(max&lt;A[i]){<br> max=A[i];<br> }<br> }<br> vector&lt;int&gt; dp(max+1,0);<br> ProduceArray(dp,max);<br> for(int x:A){<br> cout&lt;&lt;dp[x]&lt;&lt;” “;<br> }<br> return 0;<br>}</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c85f94bf90f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Time comparisons between two algorithms that evaluate the gcd of the two numbers]]></title>
            <link>https://rjtjdm.medium.com/time-comparisons-between-two-algorithms-that-evaluate-the-gcd-of-the-two-numbers-dbd005d35e4a?source=rss-1c2322dc392b------2</link>
            <guid isPermaLink="false">https://medium.com/p/dbd005d35e4a</guid>
            <category><![CDATA[euclidean-algorithm]]></category>
            <category><![CDATA[time-complexity]]></category>
            <category><![CDATA[gcd]]></category>
            <category><![CDATA[time-comparison]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Rajat Jadam]]></dc:creator>
            <pubDate>Mon, 18 May 2020 03:07:52 GMT</pubDate>
            <atom:updated>2020-05-18T03:15:37.894Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article let us study the time comparison of the two algorithms to evaluate the gcd of two numbers.</p><p>Algorithm 1: It is basically <a href="https://stackoverflow.com/questions/3980416/time-complexity-of-euclids-algorithm">Euclid’s Algorithm</a>. For time complexity details please feel free to refer the below link</p><p><a href="https://stackoverflow.com/questions/3980416/time-complexity-of-euclids-algorithm">Time complexity of Euclid&#39;s Algorithm</a></p><p>Algorithm 2: It is based on the basic definition of gcd. It takes O(n).</p><p>Here are the code implementation and output.</p><p>Code is written in CPP:-</p><p>Algorithm 1:- Faster</p><p>Algorithm 2:- Slower</p><p><a href="https://ide.geeksforgeeks.org/wSqvnR4KqR">IDE | GeeksforGeeks | A computer science portal for geeks</a></p><p>Please Don’t try to run the code at the geeks for geeks ide, it will not work. Run it on the local machine. After sufficient time you can generate interrupt and stop the program.</p><p>Here is the snapshot of the output Generated on my computer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i8fvEE_do-2jQDUupZR4cQ.png" /><figcaption>Output</figcaption></figure><p>Here we can see how clever the algorithm 1 is. It takes only 0 Milli sec time to complete such a large problem but algorithm 2 takes a huge amount of time on the other hand.</p><p>On further increasing the value of n. It will be impossible by the computer to evaluate the gcd of the number using an algorithm 2, on the other hand, it will take even less than a second using algorithm 1.</p><p>This shows how important is to select the algorithm.</p><p>Hope it matters!!!</p><p>Happy Coding.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dbd005d35e4a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Find Maximum of a Function]]></title>
            <link>https://rjtjdm.medium.com/find-maximum-of-a-function-45006b076327?source=rss-1c2322dc392b------2</link>
            <guid isPermaLink="false">https://medium.com/p/45006b076327</guid>
            <category><![CDATA[function-maxima]]></category>
            <category><![CDATA[trigonometry]]></category>
            <category><![CDATA[maximas]]></category>
            <category><![CDATA[unimodal-function]]></category>
            <category><![CDATA[sinx]]></category>
            <dc:creator><![CDATA[Rajat Jadam]]></dc:creator>
            <pubDate>Tue, 31 Mar 2020 05:48:58 GMT</pubDate>
            <atom:updated>2020-03-31T05:48:58.857Z</atom:updated>
            <content:encoded><![CDATA[<p>//You have to specify the range for which the function is Unimodal (sin(x) from 0 to PI)<br>#include&lt;iostream&gt;<br>#include&lt;math.h&gt;<br>using namespace std;<br>float function(float m){<br> return sin(m);<br>}<br>float FindMax(float start,float end)<br>{<br> while((end-start)&gt;0.0001){<br> float m1=start+(end-start)/3;<br> float m2=end-(end-start)/3; <br> if(function(m1)&lt;function(m2)){<br> start=m1;<br> }<br> else{<br> end=m2;<br> }<br> }<br> return start;<br>}<br>int main()<br>{<br> float low=0;<br> float high=M_PI;<br> cout&lt;&lt;FindMax(low,high);<br>}</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45006b076327" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BFS and DFS in a Graph]]></title>
            <link>https://rjtjdm.medium.com/bfs-and-dfs-in-a-graph-3d7462b58da2?source=rss-1c2322dc392b------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d7462b58da2</guid>
            <category><![CDATA[depth-first-search]]></category>
            <category><![CDATA[fb]]></category>
            <category><![CDATA[dfs]]></category>
            <category><![CDATA[traversals]]></category>
            <category><![CDATA[graph]]></category>
            <dc:creator><![CDATA[Rajat Jadam]]></dc:creator>
            <pubDate>Mon, 30 Mar 2020 08:58:13 GMT</pubDate>
            <atom:updated>2020-03-30T08:58:13.027Z</atom:updated>
            <content:encoded><![CDATA[<p>#include&lt;iostream&gt;<br>#include&lt;queue&gt;<br>#include&lt;stack&gt;<br>#include&lt;vector&gt;<br>using namespace std;<br>int vertices;<br>void BredthFirstSearch(vector&lt;vector&lt;int&gt;&gt; Graph){<br> queue&lt;int&gt; q;<br> int visited[vertices]={0};<br> visited[0]=1;<br> q.push(0);<br> while(!q.empty()){<br> int v=q.front();<br> q.pop();<br> visited[v]=1;<br> cout&lt;&lt;v&lt;&lt;” “;<br> for(int i=0;i&lt;vertices;i++){<br> <br> if(Graph[v][i]==1&amp;&amp;visited[i]!=1){<br> visited[i]=1; <br> q.push(i);<br> }<br> }<br> }<br> <br>}<br>void DepthFirstSearch(vector&lt;vector&lt;int&gt;&gt; Graph){<br> stack&lt;int&gt; q;<br> <br> int visited[vertices]={0};<br> visited[0]=1;<br> q.push(0);<br> while(!q.empty()){<br> int v=q.top();<br> q.pop();<br> visited[v]=1;<br> cout&lt;&lt;v&lt;&lt;” “;<br> for(int i=0;i&lt;vertices;i++){<br> <br> if(Graph[v][i]==1&amp;&amp;visited[i]!=1){<br> visited[i]=1; <br> q.push(i);<br> }<br> }<br> }<br>}<br>int main()<br>{<br> cout&lt;&lt;”Enter thr number of Vertices in a graph :”;<br> cin&gt;&gt;vertices;<br> vector&lt;vector&lt;int&gt;&gt; Graph(vertices);<br> for(int i=0;i&lt;vertices;i++){<br> Graph[i]=vector&lt;int&gt;(vertices);<br> }<br> cout&lt;&lt;”Enter the Adjacency Matrix :”;<br> for(int i=0;i&lt;vertices;i++){<br> for(int j=0;j&lt;vertices;j++){<br> cin&gt;&gt;Graph[i][j];<br> }<br> }<br> cout&lt;&lt;”Bredth Free Search: “;BredthFirstSearch(Graph);<br> cout&lt;&lt;”\n”;<br> cout&lt;&lt;”Depth Free Search: “;DepthFirstSearch(Graph);<br> cout&lt;&lt;”\n”;<br>}</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d7462b58da2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Radix Sort]]></title>
            <link>https://rjtjdm.medium.com/radix-sort-8a1c38a6dae4?source=rss-1c2322dc392b------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a1c38a6dae4</guid>
            <category><![CDATA[sort]]></category>
            <category><![CDATA[radix-sort]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[cpp]]></category>
            <dc:creator><![CDATA[Rajat Jadam]]></dc:creator>
            <pubDate>Mon, 30 Mar 2020 04:46:42 GMT</pubDate>
            <atom:updated>2020-03-30T04:46:42.422Z</atom:updated>
            <content:encoded><![CDATA[<p>#include&lt;iostream&gt;<br>#include&lt;limits.h&gt;<br>using namespace std;<br>int getMax(int[],int);<br>void Radix(int[],int);<br>void Count(int[],int,int);<br>int main()<br>{<br> int size;<br> cout&lt;&lt;”Enter the size of Array: “;<br> cin&gt;&gt;size;<br> int A[size];<br> for(int i=0;i&lt;size;i++){<br> cin&gt;&gt;A[i];<br> }<br> Radix(A,size);<br> for(int x:A){<br> cout&lt;&lt;x&lt;&lt;” “;<br> }<br>}<br>void Radix(int A[],int size)<br>{<br> int Max=getMax(A,size);<br> for(int pos=1;Max/pos&gt;0;pos*=10){<br> Count(A,size,pos);<br> }<br>}<br>int getMax(int a[],int size){<br> int max=INT_MIN;<br> for(int i=0;i&lt;size;i++){<br> if(a[i]&gt;max){<br> max=a[i];<br> }<br> }<br> return max;<br>}<br>void Count(int a[],int size,int pos){<br> int count[10]={0};<br> int temp[size]; <br> for(int i=0;i&lt;size;i++){<br> count[(a[i]/pos)%10]++;<br> }<br> for(int i=1;i&lt;10;i++){<br> count[i]+=count[i-1];<br> }<br> for(int i=size-1;i&gt;=0;i — )<br> {<br> temp[ — count[(a[i]/pos)%10]]=a[i];<br> }<br> for(int i=0;i&lt;size;i++){<br> a[i]=temp[i];<br> }<br>}</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a1c38a6dae4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fibonacci Numbers using Simple Recursive technique]]></title>
            <link>https://rjtjdm.medium.com/fibonacci-numbers-using-simple-recursive-technique-3bb49035b19d?source=rss-1c2322dc392b------2</link>
            <guid isPermaLink="false">https://medium.com/p/3bb49035b19d</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[fibonacci]]></category>
            <category><![CDATA[cpp]]></category>
            <category><![CDATA[program]]></category>
            <category><![CDATA[fibonacci-sequence]]></category>
            <dc:creator><![CDATA[Rajat Jadam]]></dc:creator>
            <pubDate>Thu, 13 Feb 2020 09:32:08 GMT</pubDate>
            <atom:updated>2020-02-13T09:32:08.878Z</atom:updated>
            <content:encoded><![CDATA[<p>#include&lt;iostream&gt;<br>using namespace std;<br>int fibonacci(int n){<br> if(n&lt;=1){<br> return n; <br> }<br> return fibonacci(n-1)+fibonacci(n-2);<br>}<br>int main(){<br> int n;<br> cout&lt;&lt;”Enter the value of N:”;<br> cin&gt;&gt;n;<br> cout&lt;&lt;fibonacci(n);<br> return 0;<br>}</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3bb49035b19d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting all prime numbers from 2 to some points of number(Sieve of Eratosthenes)]]></title>
            <link>https://rjtjdm.medium.com/getting-all-prime-numbers-from-2-to-some-points-of-number-sieve-of-eratosthenes-923991684797?source=rss-1c2322dc392b------2</link>
            <guid isPermaLink="false">https://medium.com/p/923991684797</guid>
            <category><![CDATA[prime-numbers]]></category>
            <category><![CDATA[sieve-of-eratosthenes]]></category>
            <category><![CDATA[cpp]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[primes]]></category>
            <dc:creator><![CDATA[Rajat Jadam]]></dc:creator>
            <pubDate>Sun, 09 Feb 2020 19:00:06 GMT</pubDate>
            <atom:updated>2020-02-10T10:55:23.259Z</atom:updated>
            <content:encoded><![CDATA[<p>We are interested in getting all the prime numbers from 2 to any number.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OCJ_Q2IuzZgraqMP" /><figcaption>Photo by <a href="https://unsplash.com/@briantaylor?utm_source=medium&amp;utm_medium=referral">Brian Taylor</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>#include&lt;iostream&gt;<br>using namespace std;<br>int main()<br>{<br> int n;<br> cout&lt;&lt;”Enter the value of n:”; <br> cin&gt;&gt;n;<br> if(n&gt;=2)<br> {<br> int A[n+1];<br> for(int i=0;i&lt;=n;i++){ //We can change the condition i*i&lt;n as to optimise<br> A[i]=1;<br> }<br> for(int i=2;i&lt;n+1;i++){</p><p>if(A[i]){<br> int k=2;<br> int a=i*k;<br> while(a&lt;(n+1)){<br> A[a]=0;<br> k++;<br> a=i*k;</p><p>}</p><p>}<br> }<br> cout&lt;&lt;”{“;<br> for(int i=2;i&lt;=n;i++){<br> if(A[i]){<br> cout&lt;&lt;i&lt;&lt;”,”;<br> }<br> }<br> cout&lt;&lt;”\b”;<br> cout&lt;&lt;”}”;<br> }<br> else{<br> cout&lt;&lt;”No prime number exist”;<br> }<br> <br>}</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=923991684797" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Program to find the square root of a number using Newton Raphson Method.]]></title>
            <link>https://rjtjdm.medium.com/program-to-find-the-square-root-of-a-number-using-newton-raphson-method-75c19fff34ff?source=rss-1c2322dc392b------2</link>
            <guid isPermaLink="false">https://medium.com/p/75c19fff34ff</guid>
            <category><![CDATA[newton-raphson-method]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[cpp]]></category>
            <category><![CDATA[square-roots]]></category>
            <category><![CDATA[sqrt]]></category>
            <dc:creator><![CDATA[Rajat Jadam]]></dc:creator>
            <pubDate>Sun, 09 Feb 2020 17:57:52 GMT</pubDate>
            <atom:updated>2020-02-09T17:57:52.576Z</atom:updated>
            <content:encoded><![CDATA[<p>#include&lt;iostream&gt;<br>using namespace std;<br>float absolute(float s){<br> if(s&lt;0){<br> s=-s;<br> }<br> return s;<br>}<br>float sqrt(float n){<br> int difference=0.0001;<br> int guess=1;<br> while(absolute(guess*guess-n)&gt;difference){<br> guess=(n/guess+guess)/2;<br> }<br> return guess;<br>}<br>int main(){<br> int number;<br> float root;<br> cout&lt;&lt;”Enter the number of N:”;<br> cin&gt;&gt;number;<br> root=sqrt(number);<br> cout&lt;&lt;”\nRoot : “&lt;&lt;root;<br> return 0;<br>}</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75c19fff34ff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Program to calculate the square root of a number using binary search approach.]]></title>
            <link>https://rjtjdm.medium.com/program-to-calculate-the-square-root-of-a-number-using-binary-search-approach-b35ac95bfd96?source=rss-1c2322dc392b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b35ac95bfd96</guid>
            <category><![CDATA[square-roots]]></category>
            <category><![CDATA[binary-search]]></category>
            <category><![CDATA[sqrt]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[cpp]]></category>
            <dc:creator><![CDATA[Rajat Jadam]]></dc:creator>
            <pubDate>Sun, 09 Feb 2020 17:31:26 GMT</pubDate>
            <atom:updated>2020-02-09T17:31:26.461Z</atom:updated>
            <content:encoded><![CDATA[<h3>Program to calculate the square root of a number using a binary search approach.</h3><p>#include&lt;iostream&gt;<br>using namespace std;<br>int main()<br>{<br> float n;<br> cout&lt;&lt;”Enter the value of N:”;<br> cin&gt;&gt;n;<br> float low=0;<br> float high=n;<br> float mid;<br> while((high-low)&gt;0.00001)<br> {<br> mid=(low+high)/2;<br> if((mid*mid)&lt;n){<br> low=mid;<br> }<br> else{<br> high=mid;<br> }<br> }<br> cout&lt;&lt;low;<br>}</p><p>#NOTE:</p><p>The value inside the while condition can be adjusted to give more precision. But on increasing value, We need more computations to calculate the square root.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b35ac95bfd96" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Program to print set of all divisors of a number.]]></title>
            <link>https://rjtjdm.medium.com/program-to-print-set-of-all-divisors-of-a-number-d3301aaa4f1d?source=rss-1c2322dc392b------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3301aaa4f1d</guid>
            <category><![CDATA[divisor]]></category>
            <category><![CDATA[program]]></category>
            <category><![CDATA[cpp]]></category>
            <category><![CDATA[set-of-divisors]]></category>
            <dc:creator><![CDATA[Rajat Jadam]]></dc:creator>
            <pubDate>Sun, 09 Feb 2020 12:07:37 GMT</pubDate>
            <atom:updated>2020-02-09T12:07:37.199Z</atom:updated>
            <content:encoded><![CDATA[<p>#include&lt;iostream&gt;<br>#include&lt;cmath&gt;<br>#include&lt;vector&gt;<br>using namespace std;<br>int main()<br>{<br> int a;<br> cout&lt;&lt;”Enter the value of N:”;<br> cin&gt;&gt;a;<br> vector&lt;int&gt; d;<br> for(int i=1;i&lt;(int)sqrt(a)+1;i++){<br> if(a%i==0){<br> d.push_back(i);<br> d.push_back(a/i);<br> }<br> }<br> cout&lt;&lt;”{ “;<br> for(int s:d){<br> cout&lt;&lt;s&lt;&lt;”,”;<br> }<br> cout&lt;&lt;”\b”;<br> cout&lt;&lt;” }\n”;<br> return 0;<br>}</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3301aaa4f1d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>