<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5310694419122437967</id><updated>2024-11-06T08:18:19.470+05:30</updated><category term="Data Structure"/><category term="Linked List"/><category term="Competitive Coding"/><category term="Programming Problems"/><category term="Career"/><category term="Graph"/><category term="Stack"/><title type='text'>Learn Computer programming for free Online | Code Crow</title><subtitle type='html'>Unlike from other programming websites we teach computer coding for kids and pros for free online in easy way and gives knowledge about Data structure and alogorithm in C,Java,Python and other programming languages that may help you land an online job and make your programmers day successfull. We use best data structure notes and best programming resources.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://codecrow.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='https://codecrow.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>15</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5310694419122437967.post-6700298851132848445</id><published>2019-07-04T09:00:00.000+05:30</published><updated>2019-07-04T09:00:04.674+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Competitive Coding"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming Problems"/><title type='text'>HackerRank solution in Java || Data structure problem || Hourglass problem of 2-D array</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgetqLll8SwnXEYutj_QkH5xNnwUzzOHpvH0xTtBseetQo3GIN-uTBmoPPhY-nLrCx7pIDQwTn8CdRXF6y1ROS4ZsxNNhuom2W5pns_KOMWtOqZdaPh4S-9qD0GoqfhDOTjyJoU3H4T2QiM/s1600/PicsArt_03-20-04.22.55.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Programming website about computer coding for free online in data structures and alogorithms in c,java,python etc with best programming resources&quot; border=&quot;0&quot; data-original-height=&quot;533&quot; data-original-width=&quot;1600&quot; height=&quot;212&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgetqLll8SwnXEYutj_QkH5xNnwUzzOHpvH0xTtBseetQo3GIN-uTBmoPPhY-nLrCx7pIDQwTn8CdRXF6y1ROS4ZsxNNhuom2W5pns_KOMWtOqZdaPh4S-9qD0GoqfhDOTjyJoU3H4T2QiM/s640/PicsArt_03-20-04.22.55.jpg&quot; title=&quot;Code Crow&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
In our programming website we teach computer coding to kids and pros for free online in easy way and gives knowledge about Data structure and algorithms in C,Java,Python and other programming languages that may help you land an online job and make your programmers day successful.We use best data structure notes and best programming resources.&lt;br /&gt;
Here goes the article,don&#39;t forget to share with your friends 👏💘💘&lt;br /&gt;
Let We have a 2-D Array of size 6×6.The hourglass of array is of a particular form which we will explained later in this post.For example consider the array below:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; 7&amp;nbsp; &amp;nbsp;8&amp;nbsp; &amp;nbsp;9&amp;nbsp; &amp;nbsp; 9&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 7&amp;nbsp; &amp;nbsp; &amp;nbsp;8&amp;nbsp; &amp;nbsp; 9&amp;nbsp; &amp;nbsp;9&amp;nbsp; &amp;nbsp;9&amp;nbsp; &amp;nbsp; 0&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8&amp;nbsp; &amp;nbsp; 4&amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp;8&amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; 1&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; 7&amp;nbsp; &amp;nbsp; 7&amp;nbsp; &amp;nbsp;2&amp;nbsp; &amp;nbsp; 4&amp;nbsp; &amp;nbsp; 2&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7&amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp;9&amp;nbsp; &amp;nbsp; 7&amp;nbsp; &amp;nbsp; 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The hour glass of an array will be of the form below:&lt;br /&gt;
&lt;br /&gt;
a&amp;nbsp; &amp;nbsp;b&amp;nbsp; &amp;nbsp;c&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;d&lt;br /&gt;
e&amp;nbsp; &amp;nbsp;f&amp;nbsp; &amp;nbsp;g&lt;br /&gt;
&lt;br /&gt;
That means in the matrix we have total 16 hourglass,4 horizentally and 4 vertically.&lt;br /&gt;
&lt;br /&gt;
In this problem we have to find the sum of the hourglass which have the maximum sum among other hourglasses.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #660000;&quot;&gt;&lt;u style=&quot;font-style: italic; font-weight: bold;&quot;&gt;Solution :&lt;/u&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #660000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: SourceCodePro, monospace; font-size: 15px; line-height: 20px; white-space: pre;&quot;&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;font-weight: bold;&quot;&gt;class&lt;/span&gt; Solution {&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;    &lt;span style=&quot;font-style: italic;&quot;&gt;// The hourglass sum&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;    &lt;span style=&quot;font-weight: bold;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;font-weight: bold;&quot;&gt;int&lt;/span&gt; Sum(&lt;span style=&quot;font-weight: bold;&quot;&gt;int&lt;/span&gt;[][] a) {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;        &lt;span style=&quot;font-weight: bold;&quot;&gt;int&lt;/span&gt; max = -1000; &lt;span style=&quot;color: blue;&quot;&gt;&lt;i&gt;// As sum sum can be negative&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;        &lt;span style=&quot;font-weight: bold;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;font-weight: bold;&quot;&gt;int&lt;/span&gt; i=0;i&amp;lt;4;i++) &lt;span style=&quot;color: blue;&quot;&gt;//&lt;i&gt; Because there are 4 hourglass horizontally&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;        {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;            &lt;span style=&quot;font-weight: bold;&quot;&gt;for&lt;/span&gt;(&lt;span style=&quot;font-weight: bold;&quot;&gt;int&lt;/span&gt; j=0;j&amp;lt;4;j++) &lt;/span&gt;&lt;span style=&quot;background-color: white; color: blue;&quot;&gt;//&lt;/span&gt;&lt;i style=&quot;background-color: white; color: blue;&quot;&gt; Because there are 4 hourglass vertically&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;            {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;                &lt;span style=&quot;font-weight: bold;&quot;&gt;if&lt;/span&gt;((a[i][j]+a[i][j+1]+a[i][j+2]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;+a[i+1][j+1]+a[i+2][j]+a[i+2][j+1]+a[i+2][j+2])&amp;gt;max)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;                    max=a[i][j]+a[i][j+1]+a[i][j+2]+a[i+1][j+1]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;+a[i+2][j]+a[i+2][j+1]+a[i+2][j+2];&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;            }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;        }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;        &lt;span style=&quot;font-weight: bold;&quot;&gt;return&lt;/span&gt; max;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;    }&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;Here I given only the function which will calculate the maximum hourglass sum.&lt;/span&gt;&lt;br /&gt;
Check out my &lt;a href=&quot;http://www.instagram.com/arkocodes&quot; target=&quot;_blank&quot;&gt;insta&lt;/a&gt; handle.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='https://codecrow.blogspot.com/feeds/6700298851132848445/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://codecrow.blogspot.com/2019/07/hackerrank-solution-in-java-data.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/6700298851132848445'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/6700298851132848445'/><link rel='alternate' type='text/html' href='https://codecrow.blogspot.com/2019/07/hackerrank-solution-in-java-data.html' title='HackerRank solution in Java || Data structure problem || Hourglass problem of 2-D array'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgetqLll8SwnXEYutj_QkH5xNnwUzzOHpvH0xTtBseetQo3GIN-uTBmoPPhY-nLrCx7pIDQwTn8CdRXF6y1ROS4ZsxNNhuom2W5pns_KOMWtOqZdaPh4S-9qD0GoqfhDOTjyJoU3H4T2QiM/s72-c/PicsArt_03-20-04.22.55.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5310694419122437967.post-780816656127342505</id><published>2019-06-25T21:06:00.000+05:30</published><updated>2019-06-25T21:06:57.772+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Competitive Coding"/><title type='text'>Geeks For Geeks problem|| Rotating an Array</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&amp;nbsp; &lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgetqLll8SwnXEYutj_QkH5xNnwUzzOHpvH0xTtBseetQo3GIN-uTBmoPPhY-nLrCx7pIDQwTn8CdRXF6y1ROS4ZsxNNhuom2W5pns_KOMWtOqZdaPh4S-9qD0GoqfhDOTjyJoU3H4T2QiM/s1600/PicsArt_03-20-04.22.55.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;In our programming website we teach computer coding to kids and pros for free online in easy way and gives knowledge  about Data structure and alogorithm in C,Java,Python and other programming languages that may help you land an  online job and make your programmers day successfull.We use best data structure notes and best programming resources. Here goes the article,dont forget to share with your friends ??&quot; border=&quot;0&quot; data-original-height=&quot;533&quot; data-original-width=&quot;1600&quot; height=&quot;212&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgetqLll8SwnXEYutj_QkH5xNnwUzzOHpvH0xTtBseetQo3GIN-uTBmoPPhY-nLrCx7pIDQwTn8CdRXF6y1ROS4ZsxNNhuom2W5pns_KOMWtOqZdaPh4S-9qD0GoqfhDOTjyJoU3H4T2QiM/s640/PicsArt_03-20-04.22.55.jpg&quot; title=&quot;&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Geeks For Geeks have many meticulous problems in their bag,and for any programming enthusiasts it is pleasure to solve them. In our previous post I solved one of the problems you can check&amp;nbsp; it out &lt;a href=&quot;https://codecrow.blogspot.com/2019/06/geeks-for-geeks-problem-finding.html&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Like our&amp;nbsp;&lt;a href=&quot;https://codecrow.blogspot.com/2019/06/geeks-for-geeks-problem-finding.html&quot; target=&quot;_blank&quot;&gt;previous post&lt;/a&gt;&amp;nbsp;I again want to mention that I am not doing any promotion here,I just love to solve their problems as a code lover.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; In our programming website we teach computer coding to kids and pros for free online in easy way and gives knowledge about Data structure and algorithms in C,Java,Python and other programming languages that may help you land an online job and make your programmers day successful.We use best data structure notes and best programming resources.&lt;br /&gt;
Here goes the article,don&#39;t forget to share with your friends.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Let us begin with the problem:&lt;br /&gt;
&lt;u style=&quot;color: purple; font-weight: bold;&quot;&gt;Problem Statement&lt;/u&gt;: Let we have T number of testcases. For each testcase we have an array of size&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;N.Now we have to rotate the array by d elements.The first line of input contains&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;the number of testcase T,the second line contains the size of the array N,third&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;line contains N space separated integers and fourth line contains d.&lt;br /&gt;
&lt;u style=&quot;color: purple; font-weight: bold;&quot;&gt;Example:&lt;/u&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Input:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 2 3 4 5&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Output:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 4 5 1 2&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4&lt;br /&gt;
&lt;span style=&quot;color: purple;&quot;&gt;&lt;b&gt;&lt;u&gt;Solution:&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
main() {&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int a[1000],i,j,k,N,d,T;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;T); &lt;span style=&quot;color: blue;&quot;&gt;//Taking Number of testcases&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;while(T--)&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;N); &lt;span style=&quot;color: blue;&quot;&gt;// Taking size of array&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;N;i++)&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;a[i]); &lt;span style=&quot;color: blue;&quot;&gt;//Taking array&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;d);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; for(j=d;j&amp;lt;N;j++) &lt;span style=&quot;color: blue;&quot;&gt;//printing the elements from skipping d elements to last element&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;%d &quot;,a[j]);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; for(k=0;k&amp;lt;d;k++)&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;%d &quot;,a[k]); &lt;span style=&quot;color: blue;&quot;&gt;//printing 1st d elements after printing the elements of previous segment&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp;printf(&quot;\n&quot;);&amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return 0;&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkVnvFANhTVVHsufbYX-RLEL5J9imhP3FCZuoS6A8X3OC39fi_At4fmOtS10JhgptDm6FPXBCBcQSiJ7MAtN1vvwhI3go4FoAbivLJ-YJX6UBaI6ySubyjuOxndDi8HOxLI__8-GZr8OsI/s1600/Screenshot+%2528144%2529.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Programming website about computer coding for free online in data structures and alogorithms in c,java,python etc with best programming resources&quot; border=&quot;0&quot; data-original-height=&quot;768&quot; data-original-width=&quot;1366&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkVnvFANhTVVHsufbYX-RLEL5J9imhP3FCZuoS6A8X3OC39fi_At4fmOtS10JhgptDm6FPXBCBcQSiJ7MAtN1vvwhI3go4FoAbivLJ-YJX6UBaI6ySubyjuOxndDi8HOxLI__8-GZr8OsI/s1600/Screenshot+%2528144%2529.png&quot; title=&quot;&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Check out my&amp;nbsp;&lt;a href=&quot;https://www.instagram.com/arkocodes/&quot; target=&quot;_blank&quot;&gt;instagram&lt;/a&gt;&amp;nbsp;handle to stay connected.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='https://codecrow.blogspot.com/feeds/780816656127342505/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://codecrow.blogspot.com/2019/06/geeks-for-geeks-problem-rotating-array.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/780816656127342505'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/780816656127342505'/><link rel='alternate' type='text/html' href='https://codecrow.blogspot.com/2019/06/geeks-for-geeks-problem-rotating-array.html' title='Geeks For Geeks problem|| Rotating an Array'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgetqLll8SwnXEYutj_QkH5xNnwUzzOHpvH0xTtBseetQo3GIN-uTBmoPPhY-nLrCx7pIDQwTn8CdRXF6y1ROS4ZsxNNhuom2W5pns_KOMWtOqZdaPh4S-9qD0GoqfhDOTjyJoU3H4T2QiM/s72-c/PicsArt_03-20-04.22.55.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5310694419122437967.post-2546810879402074382</id><published>2019-06-25T09:00:00.000+05:30</published><updated>2019-06-25T10:42:40.603+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Competitive Coding"/><title type='text'>Geeks For Geeks problem || Finding the immediate small element </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgetqLll8SwnXEYutj_QkH5xNnwUzzOHpvH0xTtBseetQo3GIN-uTBmoPPhY-nLrCx7pIDQwTn8CdRXF6y1ROS4ZsxNNhuom2W5pns_KOMWtOqZdaPh4S-9qD0GoqfhDOTjyJoU3H4T2QiM/s1600/PicsArt_03-20-04.22.55.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;In our programming website we teach computer coding to kids and pros for free online in easy way and gives knowledge  about Data structure and alogorithm in C,Java,Python and other programming languages that may help you land an  online job and make your programmers day successfull.We use best data structure notes and best programming resources. Here goes the article,dont forget to share with your friends ??&quot; border=&quot;0&quot; data-original-height=&quot;533&quot; data-original-width=&quot;1600&quot; height=&quot;212&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgetqLll8SwnXEYutj_QkH5xNnwUzzOHpvH0xTtBseetQo3GIN-uTBmoPPhY-nLrCx7pIDQwTn8CdRXF6y1ROS4ZsxNNhuom2W5pns_KOMWtOqZdaPh4S-9qD0GoqfhDOTjyJoU3H4T2QiM/s640/PicsArt_03-20-04.22.55.jpg&quot; title=&quot;Code Crow&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Geeks for Geeks is very popular and helpful website for Computer Science students,they have an excellent collection of questions related to coding,interview experiences and so on.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; In this article we will solve a array related problem in which we are given an an array and we have to print the next element of each element if the element is small than the previous element otherwise we have to print -1.&lt;br /&gt;
In our programming website we teach computer coding to kids and pros for free online in easy way and gives knowledge about Data structure and algorithms in C,Java,Python and other programming languages that may help you land an online job and make your programmers day successful.We use best data structure notes and best programming resources.&lt;br /&gt;
Here goes the article,don&#39;t forget to share with your friends 😊😊&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;Let me very clear before we going to solve the problem that I am not doing any promotion of Geeks For Geeks its just that I love problem solving from this kind of websites and I also recommend you to do so.Enough talking though lets jump on to the problem&amp;nbsp; -------&lt;br /&gt;
&lt;b style=&quot;color: blue; text-decoration-line: underline;&quot;&gt;&lt;u&gt;Problem Statement&lt;/u&gt;&lt;/b&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;u&gt;:&lt;/u&gt; &lt;/span&gt;Let we have T testcases. For each case we have an array of given size.For each&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; array we have to print the next element of each element if the next element is&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; smaller than the previous element otherwise we will print -1.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;The first line of input is T=number of testcase;each testcase have 2 lines of input,&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;first line is the size of the array,and the second line is the elements separated by&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;space.&lt;br /&gt;
&lt;u style=&quot;color: blue; font-weight: bold;&quot;&gt;Example:&lt;/u&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Input:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 3 2 7 2&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8 5 9 2&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Output:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -1 2 -1 -1&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5 -1 2 -1&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;&lt;u&gt;Solution:&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&amp;nbsp;main() {&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int T,N,a[100000],i;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;T); &lt;span style=&quot;color: orange;&quot;&gt;// Taking input of number of test cases&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;while(T--)&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;N); &lt;span style=&quot;color: orange;&quot;&gt;//Taking input of size of the array for each testcase&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;//Taking input of the array&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;N;i++)&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;a[i]);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;N-1;i++)&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;//Check wheather the next element is smaller than the previous element upto the 2nd last element&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(a[i]&amp;gt;a[i+1])&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;%d &quot;,a[i+1]);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;-1 &quot;);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&lt;span style=&quot;color: orange;&quot;&gt;//Print -1 for the last element as it has no element to compare with&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp;printf(&quot;-1&quot;);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp;printf(&quot;\n&quot;);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtPCrAIDLDylADkW8HNwo5YbIMRAfgyDckGATNzBVlhyFjzA9vIOC_np04NwuG0y9nTuPk1q-f5uUUD-Q64rKhrDfCQn1dE5cjwFZ9iyyg1S1ZKyNsyaS0tYCpdaMjModJL2J0qcmH-TE_/s1600/Screenshot+%2528143%2529.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Programming website about computer coding for free online in data structures and alogorithms in c,java,python etc with best programming resources&quot; border=&quot;0&quot; data-original-height=&quot;768&quot; data-original-width=&quot;1366&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtPCrAIDLDylADkW8HNwo5YbIMRAfgyDckGATNzBVlhyFjzA9vIOC_np04NwuG0y9nTuPk1q-f5uUUD-Q64rKhrDfCQn1dE5cjwFZ9iyyg1S1ZKyNsyaS0tYCpdaMjModJL2J0qcmH-TE_/s1600/Screenshot+%2528143%2529.png&quot; title=&quot;Geek Coder&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; keep follow our blog for that kind of posts and don&#39;t forget to follow our &lt;a href=&quot;https://www.instagram.com/arkocodes/&quot; target=&quot;_blank&quot;&gt;social&lt;/a&gt; handels.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='https://codecrow.blogspot.com/feeds/2546810879402074382/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://codecrow.blogspot.com/2019/06/geeks-for-geeks-problem-finding.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/2546810879402074382'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/2546810879402074382'/><link rel='alternate' type='text/html' href='https://codecrow.blogspot.com/2019/06/geeks-for-geeks-problem-finding.html' title='Geeks For Geeks problem || Finding the immediate small element '/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgetqLll8SwnXEYutj_QkH5xNnwUzzOHpvH0xTtBseetQo3GIN-uTBmoPPhY-nLrCx7pIDQwTn8CdRXF6y1ROS4ZsxNNhuom2W5pns_KOMWtOqZdaPh4S-9qD0GoqfhDOTjyJoU3H4T2QiM/s72-c/PicsArt_03-20-04.22.55.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5310694419122437967.post-7504541695564190263</id><published>2019-03-22T15:31:00.000+05:30</published><updated>2019-03-22T15:31:48.387+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Graph"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming Problems"/><title type='text'>How to represent a graph in data structure through Adjacency matrix | Data Structure Problems</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgetqLll8SwnXEYutj_QkH5xNnwUzzOHpvH0xTtBseetQo3GIN-uTBmoPPhY-nLrCx7pIDQwTn8CdRXF6y1ROS4ZsxNNhuom2W5pns_KOMWtOqZdaPh4S-9qD0GoqfhDOTjyJoU3H4T2QiM/s1600/PicsArt_03-20-04.22.55.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;In our programming website we teach computer coding to kids and pros for free online in easy way and gives knowledge  about Data structure and alogorithm in C,Java,Python and other programming languages that may help you land an  online job and make your programmers day successfull.We use best data structure notes and best programming resources. &quot; border=&quot;0&quot; data-original-height=&quot;533&quot; data-original-width=&quot;1600&quot; height=&quot;212&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgetqLll8SwnXEYutj_QkH5xNnwUzzOHpvH0xTtBseetQo3GIN-uTBmoPPhY-nLrCx7pIDQwTn8CdRXF6y1ROS4ZsxNNhuom2W5pns_KOMWtOqZdaPh4S-9qD0GoqfhDOTjyJoU3H4T2QiM/s640/PicsArt_03-20-04.22.55.jpg&quot; title=&quot;Codecrow&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Graph is an important part of data structure &amp;amp; algothims,if you keen to learn coding you can&#39;t miss graph in data structure,in this article I try to keep the explanation as simple as possible.You know learn programming in coding classes is just boarning.If you want cool stuff you must practice problems.Learn coding through ppractice is the best way.Here also I tell you about graph by examples.&lt;br /&gt;
But at first&amp;nbsp; I want to give you a brief intro about our blog;&lt;br /&gt;
In our programming website we teach computer coding to kids and pros for free online in easy way and gives knowledge about Data structure and alogorithm in C,Java,Python and other programming languages that may help you land an online job and make your programmers day successfull.We use best data structure notes and best programming resources.&lt;br /&gt;
Here goes the article,thanks for having patience &amp;amp; don&#39;t forget to share with your friends 👌&lt;br /&gt;
&lt;b&gt;Graph&lt;/b&gt; is an important part of data structure,it is a collection of some nodes called vertices and some lines called edges.&lt;br /&gt;
Graphs are mainly of two types,&lt;br /&gt;
i)undirected graph &amp;amp; ii)directed graph.&lt;br /&gt;
&lt;b&gt;undirected graph&lt;/b&gt; or simple graph is a graph without any direction &amp;amp; &lt;b&gt;directed graph &lt;/b&gt;is a graph&amp;nbsp; which have directions,the directions are basically represented by arrows.&lt;br /&gt;
But a computer couldn&#39;t unnderstand those pictorial representation with nodes,edges,arrows right? So we have to find a way to represent them in way that can be understood by the computer also.&lt;br /&gt;
There are &lt;b&gt;two ways to represent a graph &lt;/b&gt;they are i)&lt;b&gt;Adjacency Matrix &lt;/b&gt;and ii)&lt;b&gt;Adjacency list.&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: yellow;&quot;&gt;In this article we will talk about Adjacency Matrix only.&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;Adjacency matrix &lt;/b&gt;is a square Matrix&amp;nbsp; used to represent a graph.It consists 0&#39;s and 1&#39;s. 0 represent no age present between pair of vertices and 1 represent an edge present between pair of vertices.&lt;br /&gt;
Lets us take some examples so that you can understand them clearly.Don&#39;t worry it will be easy after understanding them you will also enjoy them,trust me. ☺&lt;br /&gt;
Here goes the examples:&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLvzNyNxpqYVs1yZGfJbb45MDP9wN9YM4b28CCXt16V08w5jCz9MwcNw_SqqHwfCnEMKcangApRBnoRF3gowQNHbpskOEaoSy48kmw5tlyCGJVgD-r_mWVIJdmfYdoAtuqjsoS-koTiCLN/s1600/WhatsApp+Image+2019-03-21+at+22.40.00.jpeg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;In our programming website we teach computer coding to kids and pros for free online in easy way and gives knowledge  about Data structure and alogorithm in C,Java,Python and other programming languages that may help you land an  online job and make your programmers day successfull.We use best data structure notes and best programming resources. &quot; border=&quot;0&quot; data-original-height=&quot;499&quot; data-original-width=&quot;544&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLvzNyNxpqYVs1yZGfJbb45MDP9wN9YM4b28CCXt16V08w5jCz9MwcNw_SqqHwfCnEMKcangApRBnoRF3gowQNHbpskOEaoSy48kmw5tlyCGJVgD-r_mWVIJdmfYdoAtuqjsoS-koTiCLN/s1600/WhatsApp+Image+2019-03-21+at+22.40.00.jpeg&quot; title=&quot;Adjacency Matrix&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Adjacency Matrix for a undirected Graph&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKdL5EDTc8A9isyyfIgh7SxNu5FpKXKSJYXPw45LD-kzoE5iTa_ISeKPLnPPxkkvyLj7qeTTaHPsb1drJs5w6qNYEu-VaBztr_bcOfmDaQrE7a7r5p5H76Jm6Sd332cejx00qzJ7BYTQVw/s1600/WhatsApp+Image+2019-03-21+at+22.38.54.jpeg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;In our programming website we teach computer coding to kids and pros for free online in easy way and gives knowledge  about Data structure and alogorithm in C,Java,Python and other programming languages that may help you land an  online job and make your programmers day successfull.We use best data structure notes and best programming resources. Here goes the article,dont forget to share with your friends ??&quot; border=&quot;0&quot; data-original-height=&quot;348&quot; data-original-width=&quot;470&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKdL5EDTc8A9isyyfIgh7SxNu5FpKXKSJYXPw45LD-kzoE5iTa_ISeKPLnPPxkkvyLj7qeTTaHPsb1drJs5w6qNYEu-VaBztr_bcOfmDaQrE7a7r5p5H76Jm6Sd332cejx00qzJ7BYTQVw/s1600/WhatsApp+Image+2019-03-21+at+22.38.54.jpeg&quot; title=&quot;Adjaceny matrix&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Adjacency matrix for an directed Graph&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
Hope this wil help you.In the next article I will&amp;nbsp; tell you about Adjacency List,so stay tuned &amp;amp; please share this article with your&amp;nbsp; friends,I really need your support.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='https://codecrow.blogspot.com/feeds/7504541695564190263/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://codecrow.blogspot.com/2019/03/how-to-represent-graph-in-data-structure.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/7504541695564190263'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/7504541695564190263'/><link rel='alternate' type='text/html' href='https://codecrow.blogspot.com/2019/03/how-to-represent-graph-in-data-structure.html' title='How to represent a graph in data structure through Adjacency matrix | Data Structure Problems'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgetqLll8SwnXEYutj_QkH5xNnwUzzOHpvH0xTtBseetQo3GIN-uTBmoPPhY-nLrCx7pIDQwTn8CdRXF6y1ROS4ZsxNNhuom2W5pns_KOMWtOqZdaPh4S-9qD0GoqfhDOTjyJoU3H4T2QiM/s72-c/PicsArt_03-20-04.22.55.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5310694419122437967.post-4490263588294864212</id><published>2019-03-21T03:43:00.001+05:30</published><updated>2019-03-21T03:43:44.090+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Career"/><title type='text'>Best websites to learn programming for free onine | A step by step guide that you can&#39;t miss</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgetqLll8SwnXEYutj_QkH5xNnwUzzOHpvH0xTtBseetQo3GIN-uTBmoPPhY-nLrCx7pIDQwTn8CdRXF6y1ROS4ZsxNNhuom2W5pns_KOMWtOqZdaPh4S-9qD0GoqfhDOTjyJoU3H4T2QiM/s1600/PicsArt_03-20-04.22.55.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Programming website about computer coding for free online in data structures and alogorithms in c,java,python etc with best programming resources&quot; border=&quot;0&quot; data-original-height=&quot;533&quot; data-original-width=&quot;1600&quot; height=&quot;213&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgetqLll8SwnXEYutj_QkH5xNnwUzzOHpvH0xTtBseetQo3GIN-uTBmoPPhY-nLrCx7pIDQwTn8CdRXF6y1ROS4ZsxNNhuom2W5pns_KOMWtOqZdaPh4S-9qD0GoqfhDOTjyJoU3H4T2QiM/s640/PicsArt_03-20-04.22.55.jpg&quot; title=&quot;Code Crow Logo&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Programming is the hottest trend now a days and here I provide best websites to learn programming for free online.The list is &lt;b&gt;designed to make you a pro from a complete newbie&lt;/b&gt;,also this list is constructed by my point of view &amp;amp; if you disagree or add something new that I missed out please let me know in the comments.&lt;br /&gt;
Before starting with the list I want to introduce my website&amp;nbsp;&lt;a href=&quot;https://codecrow.blogspot.com/&quot; target=&quot;_blank&quot;&gt;Code Crow&lt;/a&gt;&amp;nbsp;to you so that you will be able to know what kind of posts are present in this blog and if you want to be updated when we a put a new post please subscribe to our email list.😀&lt;br /&gt;
&lt;b&gt;Intro:&lt;/b&gt;In our programming website we teach computer coding to kids and pros for free online in easy way and gives knowledge about Data structure and alogorithm in C,Java,Python and other programming languages that may help you land an online job and make your programmers day successfull.We use best data structure notes and best programming resources.&lt;br /&gt;
Here goes the article,dont forget to share with your friends 💗,I divide the list in three segments&lt;br /&gt;
&lt;span style=&quot;background-color: orange;&quot;&gt;Theory-&amp;gt;Competitive coding-&amp;gt;Placement Preparation&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Grabing knowledge(to have a grasp in theory):&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;
1.&amp;nbsp;&lt;a href=&quot;https://www.geeksforgeeks.org/&quot; target=&quot;_blank&quot;&gt;Geeks for Geeks&lt;/a&gt;&amp;nbsp;: This is the &lt;b&gt;best website for begineers&lt;/b&gt; that I personally feel.Here you have the access to learn many Computer &amp;amp;&amp;nbsp; programming related subjects (mostly the theory part) in a very lucid way.Here you can also practice competitive prrogramming and prepare yourself for placement and job interview in a very structured manner.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Competitive coding:&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;
1.&lt;a href=&quot;https://www.hackerrank.com/&quot; target=&quot;_blank&quot;&gt;Hackerrank&lt;/a&gt;&amp;nbsp;: After having a brief grasp in theory you can apply your knowledge to hackerrank practise questions.This site also&lt;b&gt; host many coding competitions &lt;/b&gt;that will richly develope yiour programming skills.&lt;br /&gt;
2.&lt;a href=&quot;https://www.hackerearth.com/&quot; target=&quot;_blank&quot;&gt;Hackerearth&lt;/a&gt;&amp;nbsp;:This is also like hackerrank and it also have many mind blowing &lt;b&gt;coding problems for beginners with a soothing user friendly interface&lt;/b&gt;.I must mention that I personally have a soft corner for a hackerearth because it is the first competitive programming platform that I used.&lt;br /&gt;
3.&lt;a href=&quot;https://www.codechef.com/&quot; target=&quot;_blank&quot;&gt;Codechef:&lt;/a&gt;&amp;nbsp;: The only reason I put Codechef in number three because you must try it after you get familiar with hackerrank &amp;amp; hackerearth beacuse it is slightly tough compare those two. But it is platform worth of to put your time in it,it will make you a &lt;b&gt;complete pro in competitive programming.&lt;/b&gt;&lt;br /&gt;
4.&lt;a href=&quot;https://www.topcoder.com/&quot; target=&quot;_blank&quot;&gt;Topcoder&lt;/a&gt;&amp;nbsp;:The most popular competitive coding platform around the globe.It organises &lt;b&gt;high paying coding competiton&lt;/b&gt; for developers.You must try it after you spend a sufficient time in competitive programming in other platforms.&lt;br /&gt;
5.&lt;a href=&quot;https://codeforces.com/&quot; target=&quot;_blank&quot;&gt;Codeforces&lt;/a&gt;&amp;nbsp;: I personally didn&#39;t use it but is also a very popular platform for coding and&amp;nbsp; many of my friends use it.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Placement Preparation:&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;
1.&lt;a href=&quot;https://www.interviewbit.com/&quot; target=&quot;_blank&quot;&gt;Interviewbit&lt;/a&gt;&amp;nbsp;:&amp;nbsp; This is the most recomended &lt;b&gt;platform for placement focused preparetion&lt;/b&gt;.You can&#39;t go to an interview before checking out this website it has also the mock interview facility.&lt;br /&gt;
2.&amp;nbsp;&lt;a href=&quot;https://leetcode.com/&quot; target=&quot;_blank&quot;&gt;Leetcode&lt;/a&gt;&amp;nbsp;: you should check out this also after having a tour through interview bit.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Hope you like this post,feel free to give your suggestions in comment,I will shout out to you 👱&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Share with your friends if you find this helpfull and it also motivates me.&lt;br /&gt;
Keep follow our blog,in the next post I will post about the&lt;b&gt; best youtube channel for programming&lt;/b&gt;,still then bye bye👋&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='https://codecrow.blogspot.com/feeds/4490263588294864212/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://codecrow.blogspot.com/2019/03/best-websites-to-learn-programming-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/4490263588294864212'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/4490263588294864212'/><link rel='alternate' type='text/html' href='https://codecrow.blogspot.com/2019/03/best-websites-to-learn-programming-for.html' title='Best websites to learn programming for free onine | A step by step guide that you can&#39;t miss'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgetqLll8SwnXEYutj_QkH5xNnwUzzOHpvH0xTtBseetQo3GIN-uTBmoPPhY-nLrCx7pIDQwTn8CdRXF6y1ROS4ZsxNNhuom2W5pns_KOMWtOqZdaPh4S-9qD0GoqfhDOTjyJoU3H4T2QiM/s72-c/PicsArt_03-20-04.22.55.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5310694419122437967.post-2657642793142942745</id><published>2019-03-17T15:36:00.001+05:30</published><updated>2019-03-17T15:36:31.938+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Linked List"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming Problems"/><title type='text'>How to create single linked list? | Data structure Problem | coding for beginners</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s1600/crow.jfif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;coding courses about computer coding for beginners free online in data structures and alogorithms in c,java,python with best programming resources&quot; border=&quot;0&quot; data-original-height=&quot;213&quot; data-original-width=&quot;639&quot; height=&quot;212&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s640/crow.jfif&quot; title=&quot;Learn computer coding online&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
For coding courses about computer coding for beginners free online in data structures and alogorithms in c,java,python with best programming resources follow our &lt;a href=&quot;https://codecrow.blogspot.com/&quot; target=&quot;_blank&quot;&gt;blog&lt;/a&gt;&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
In our programming website we teach computer coding to kids and pros for free online in easy way and gives knowledge about Data structure and alogorithm in C,Java,Python and other programming languages that may help you land an online job and make your programmers day successfull.We use best data structure notes and best programming resources.&lt;br /&gt;
&lt;br /&gt;
Here goes the article,dont forget to share with your friends 😉&lt;br /&gt;
&lt;br /&gt;
#include&quot;stdio.h&quot;&lt;br /&gt;
#include&quot;stdlib.h&quot;&lt;br /&gt;
struct node&lt;br /&gt;
{&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int data;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;struct node *next;&lt;br /&gt;
};&lt;br /&gt;
struct node *start; &lt;span style=&quot;color: blue;&quot;&gt;//set the head of the list as global&lt;/span&gt;&lt;br /&gt;
struct node *createlist(int d)&lt;br /&gt;
{&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;struct node *ptr,*p;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int i;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;ptr=(struct node *)malloc(sizeof(struct node)); &lt;span style=&quot;color: blue;&quot;&gt;//allocating memory for the added node&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;ptr-&amp;gt;data=d;&lt;span style=&quot;color: blue;&quot;&gt; //allocate data part&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(start==NULL)&lt;span style=&quot;color: blue;&quot;&gt; //when list is empty&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ptr-&amp;gt;next=start;&lt;span style=&quot;color: blue;&quot;&gt; //set the address part of the node to head which is null&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;start=ptr; &lt;span style=&quot;color: blue;&quot;&gt;//set the added node as head&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;p=start;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;while(p-&amp;gt;next!=NULL)&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;p=p-&amp;gt;next; &lt;span style=&quot;color: blue;&quot;&gt;//traverse the list untill p points to the lat node&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;p-&amp;gt;next=ptr; &lt;span style=&quot;color: blue;&quot;&gt;//link the address part of the last node to new node&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ptr-&amp;gt;next=NULL; &lt;span style=&quot;color: blue;&quot;&gt;//make the address part of the new node null so that it can become last node&lt;/span&gt;&lt;br /&gt;
}&lt;br /&gt;
return start; &lt;span style=&quot;color: blue;&quot;&gt;//return head&lt;/span&gt;&lt;br /&gt;
}&lt;br /&gt;
void display(struct node *start)&lt;br /&gt;
{&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;struct node *p;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;p=start;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;while(p!=NULL)&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;%d-&amp;gt;&quot;,p-&amp;gt;data);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;p=p-&amp;gt;next;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
}&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int n,i,d;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;enter the number of nodes\n&quot;);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;n);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for(i=1;i&amp;lt;=n;i++)&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;%dth node value:&quot;,i);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;d);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;createlist(d);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;The list is:&quot;);&lt;br /&gt;
display(start);&lt;br /&gt;
return 0;&lt;br /&gt;
}&lt;br /&gt;
Here I also attach the output of the program:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3Myr0-GelH11PVszH8nec4FEeQRYtvVMTxrZuOQAkzihgPbWCV_4zPeaiNnb6m1b4ov-7M_bMVCm3W1Ay2t7CpUBW1gYQUDKAYRYue11kjHRYHgd0pw2yi9xlR1xSkFvZg9pNGbs-tD2k/s1600/Screenshot+%252870%2529.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;coding courses about computer coding for beginners free online in data structures and alogorithms in c,java,python with best programming resources&quot; border=&quot;0&quot; data-original-height=&quot;768&quot; data-original-width=&quot;1366&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3Myr0-GelH11PVszH8nec4FEeQRYtvVMTxrZuOQAkzihgPbWCV_4zPeaiNnb6m1b4ov-7M_bMVCm3W1Ay2t7CpUBW1gYQUDKAYRYue11kjHRYHgd0pw2yi9xlR1xSkFvZg9pNGbs-tD2k/s1600/Screenshot+%252870%2529.png&quot; title=&quot;Data structure problem&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
feel free to comment for any problem regarding this solution😃😃&lt;br /&gt;
Check out our other social media handels below,where we update you when our next post is coming:&lt;br /&gt;
&lt;a href=&quot;https://www.facebook.com/codecrowblog/&quot; target=&quot;_blank&quot;&gt;Facebook&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://www.linkedin.com/company/codecrowblog&quot; target=&quot;_blank&quot;&gt;linkedin&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://www.instagram.com/codecrowblog/&quot; target=&quot;_blank&quot;&gt;Instagram&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://codecrowblog.quora.com/&quot; target=&quot;_blank&quot;&gt;Quora&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='https://codecrow.blogspot.com/feeds/2657642793142942745/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://codecrow.blogspot.com/2019/03/how-to-create-single-linked-list-data.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/2657642793142942745'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/2657642793142942745'/><link rel='alternate' type='text/html' href='https://codecrow.blogspot.com/2019/03/how-to-create-single-linked-list-data.html' title='How to create single linked list? | Data structure Problem | coding for beginners'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s72-c/crow.jfif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5310694419122437967.post-7687314135962639793</id><published>2019-03-12T01:22:00.000+05:30</published><updated>2019-03-14T22:13:14.197+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Competitive Coding"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Linked List"/><title type='text'>Data Structure:Deleting a node in linked list,Recursive approach in C programming</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s1600/crow.jfif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;213&quot; data-original-width=&quot;639&quot; height=&quot;211&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s640/crow.jfif&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h2&gt;
Hackerrank problem 5:Data Structure:Deleting a node in linked list,Recursive approach in C programming&lt;/h2&gt;
&lt;div&gt;
&lt;div&gt;
In our Programming website about computer coding for free online in data structures and alogorithms in c,java,python etc we try solve progaming,computer coding in easy way with best programming resources.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
Here I use recursive approach to solve this;&lt;span style=&quot;color: orange;&quot;&gt;I only wrote the function in this case&lt;/span&gt;;the code is as follows:&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;background-color: #fffffe; font-family: monospace; font-size: 15px; line-height: 20px; white-space: pre;&quot;&gt;
&lt;div&gt;
&lt;span style=&quot;color: green;&quot;&gt;/ this is solution function&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: green;&quot;&gt; / Prerequsite:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: green;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: green;&quot;&gt;  Node &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: green;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: green;&quot;&gt;      int data;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: green;&quot;&gt;      Node* link;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: green;&quot;&gt;  };&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Node* deleteNode(Node* root, &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; pos) {&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;(pos==&lt;span style=&quot;color: #09885a;&quot;&gt;0&lt;/span&gt;)&lt;/div&gt;
&lt;div&gt;
{&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; root-&amp;gt;link; &lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
} &lt;/div&gt;
&lt;div&gt;
root-&amp;gt;link=deleteNode(root-&amp;gt;link, pos-&lt;span style=&quot;color: #09885a;&quot;&gt;1&lt;/span&gt;);&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; root;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
}&lt;br /&gt;
/&lt;span style=&quot;color: #38761d;&quot;&gt;Here pos means position &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='https://codecrow.blogspot.com/feeds/7687314135962639793/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://codecrow.blogspot.com/2019/03/deleting-node-in-linked-listrecursive.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/7687314135962639793'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/7687314135962639793'/><link rel='alternate' type='text/html' href='https://codecrow.blogspot.com/2019/03/deleting-node-in-linked-listrecursive.html' title='Data Structure:Deleting a node in linked list,Recursive approach in C programming'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s72-c/crow.jfif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5310694419122437967.post-3160683900209508010</id><published>2019-03-10T16:02:00.002+05:30</published><updated>2019-03-14T21:29:16.820+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Linked List"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming Problems"/><title type='text'>Data Structure problem in C: Josephus Circle(Taking elements manually) | Competitive coding</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s1600/crow.jfif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;213&quot; data-original-width=&quot;639&quot; height=&quot;132&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s400/crow.jfif&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;background-color: yellow;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;Data Structure problem in C: Josephus Circle(Taking elements manually) | Competitive coding:&lt;/span&gt;&lt;/h4&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;In our programming website we teach computer coding to kids and pros for free online in easy way and gives knowledge about Data structure and alogorithm in C,Java,Python&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;
&lt;div&gt;
&amp;nbsp;and other programming languages that may help you land an online job and make your programmers day successfull.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
We use best data structure notes and best programming resources. Here goes the article,dont forget to share with your friends 😃&lt;/div&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;background-color: yellow;&quot;&gt;Here we take elements manually of values that we want and&lt;span style=&quot;font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/span&gt;&amp;nbsp;are inserted in a circle waiting to be executed.counting begins at a specified point in a circle and proceeds around the circle in a specified direction. After a specified number of elements skipped,the next element is executed. The procedure is repeated with the remaining elements,starting with the next element,going in the same direction and skipping the same number of element,untill only one element remains,and is freed.&lt;/span&gt;&lt;/h4&gt;
&lt;div&gt;
The code is as follows:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
#include&quot;stdio.h&quot;&lt;/div&gt;
&lt;div&gt;
#include&quot;stdlib.h&quot;&lt;/div&gt;
&lt;div&gt;
struct node&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
{&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int data;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;struct node *next;&lt;/div&gt;
&lt;div&gt;
}*last=NULL;&lt;/div&gt;
&lt;div&gt;
struct node *q=NULL;&lt;/div&gt;
&lt;div&gt;
struct node *insert(int d)&lt;/div&gt;
&lt;div&gt;
{&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;struct node* p;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;struct node *q;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;p=(struct node*)malloc(sizeof(struct node));&lt;span style=&quot;color: #38761d;&quot;&gt;//allocating memory for the node to be inserted&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;p-&amp;gt;data=d;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(last==NULL) &lt;span style=&quot;color: #38761d;&quot;&gt;//when list is empty&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;last=p;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;p-&amp;gt;next=last;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;q=last;&lt;span style=&quot;color: #38761d;&quot;&gt; //point to the last(next of first)element&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;while(q-&amp;gt;next!=last)&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;q=q-&amp;gt;next; &lt;span style=&quot;color: #38761d;&quot;&gt;//traversing list&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;//adding new element&lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;q-&amp;gt;next=p;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;p-&amp;gt;next=last;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return last;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
void display(struct node *last)&lt;/div&gt;
&lt;div&gt;
{&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;struct node *q;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;q=last;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;while(q-&amp;gt;next!=last)&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;%d\t&quot;,q-&amp;gt;data);&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;q=q-&amp;gt;next;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;%d&quot;,q-&amp;gt;data);&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;\n&quot;);&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
int main()&lt;/div&gt;
&lt;div&gt;
{&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int d,i,n,h,j;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;struct node *p,*q;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;enter the number of item\n&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;n);&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for(i=1;i&amp;lt;=n;i++)&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;enter the node value\n&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;d);&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;insert(d);&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;display(last);&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;enter the no of node to be skiped\n&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;h);&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;//logic of skip &amp;amp; execute&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; q=last;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; while(q-&amp;gt;next!=q)&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; {&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for(j=1;j&amp;lt;h;j++)&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;q=q-&amp;gt;next;&lt;span style=&quot;color: #38761d;&quot;&gt;//points to the h&#39;th node&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;p=q-&amp;gt;next; &lt;span style=&quot;color: #38761d;&quot;&gt;//point to the h+1&#39;th node,i.e the node to be deleted&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;q-&amp;gt;next=p-&amp;gt;next;&lt;span style=&quot;color: #38761d;&quot;&gt;//the desired element is deleted&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;%d will execute\n&quot;,p-&amp;gt;data);&lt;span style=&quot;color: #38761d;&quot;&gt;//print the element which is executed&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;q=p-&amp;gt;next;&lt;span style=&quot;color: #38761d;&quot;&gt;//now the element after the removed element becomes last and the process goes on&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
printf(&quot;\n%d will unchanged&quot;,q-&amp;gt;data);&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpiT28WV9NuW1-yu9CRpU4cMZWV6k6tBInVncI4uq5E3DUef-euwuDxZPiW7yIb_eIVw61m-rs7VGfpExvUwdjQV-2dFLJEq35BWqhMQFTNYcF3NERrJjtHm0YDjGZ2d_2Nv8cDJMrnYVp/s1600/Screenshot+%252866%2529.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;768&quot; data-original-width=&quot;1366&quot; height=&quot;356&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpiT28WV9NuW1-yu9CRpU4cMZWV6k6tBInVncI4uq5E3DUef-euwuDxZPiW7yIb_eIVw61m-rs7VGfpExvUwdjQV-2dFLJEq35BWqhMQFTNYcF3NERrJjtHm0YDjGZ2d_2Nv8cDJMrnYVp/s640/Screenshot+%252866%2529.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='https://codecrow.blogspot.com/feeds/3160683900209508010/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://codecrow.blogspot.com/2019/03/josephus-circletaking-elements-manually.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/3160683900209508010'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/3160683900209508010'/><link rel='alternate' type='text/html' href='https://codecrow.blogspot.com/2019/03/josephus-circletaking-elements-manually.html' title='Data Structure problem in C: Josephus Circle(Taking elements manually) | Competitive coding'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s72-c/crow.jfif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5310694419122437967.post-275674793512397913</id><published>2019-03-05T22:16:00.003+05:30</published><updated>2019-03-14T21:29:49.893+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Linked List"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming Problems"/><title type='text'>Data structure Problem | Josephus Circle in Data structure using C |The easiest way you never thought</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s1600/crow.jfif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;213&quot; data-original-width=&quot;639&quot; height=&quot;212&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s640/crow.jfif&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Data structure Problem | Josephus Circle in Data structure using C |The easiest way you never thought&lt;/h2&gt;
&lt;div&gt;
&lt;div&gt;
In our programming website we teach computer coding to kids and pros for free online in easy way and gives knowledge about Data structure and alogorithm in C,Java,Python&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;and other programming languages that may help you land an online job and make your programmers day successfull.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
We use best data structure notes and best programming resources. Here goes the article,dont forget to share with your friends 😃&lt;/div&gt;
&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Josephus Circle:&lt;/h2&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: orange;&quot;&gt;people are standing in a circle waiting to be executed.counting begins at a specified point in a circle and proceeds around the circle in a specified direction. After a specified number of people skipped,the next person is executed. The procedure is repeatedwith the remaining people,starting with the next person,going in the same direction and skipping the same number of people,untill only one person remains,and is freed.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;The c program to implement this problem is given below:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;#include&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;#include&amp;lt;stdlib.h&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp;struct node&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;
&lt;/span&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&amp;nbsp;{&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int data;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; struct node *link;&lt;/div&gt;
&lt;div&gt;
};&lt;/div&gt;
&lt;div&gt;
void skipexecute(int,struct node *);&lt;/div&gt;
&lt;div&gt;
struct node *root=NULL,*p=NULL;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;main()&lt;/div&gt;
&lt;div&gt;
{&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int count=1,number,m;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;struct node *temp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;enter the value of number:\n&quot;);&amp;nbsp; &amp;nbsp;//total number of elements in list&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;number);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;enter the value of m:\n&quot;);&amp;nbsp; // we have to&amp;nbsp; remove&amp;nbsp; m+1th element each time&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; scanf(&quot;%d&quot;,&amp;amp;m);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while(count&amp;lt;=number)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; temp=(struct node*)malloc(sizeof(struct node));&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; temp-&amp;gt;data=count++;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(root==NULL)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; root=temp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; temp-&amp;gt;link=root;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; p=root;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while(p-&amp;gt;link!=root)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; p=p-&amp;gt;link;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; p-&amp;gt;link=temp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; temp-&amp;gt;link=root;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;List in circuler order:\n&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; p=root;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while(p-&amp;gt;link!=root)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;printf(&quot;%d-&amp;gt;&quot;,p-&amp;gt;data);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; p=p-&amp;gt;link;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;%d&quot;,p-&amp;gt;data);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\n&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; skipexecute(m,root);&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
void skipexecute(int m,struct node *front)&lt;/div&gt;
&lt;div&gt;
{&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;struct&amp;nbsp; node *flag;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int count1=1;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while(front-&amp;gt;link!=front)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; count1=1;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while(count1!=m+1)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; flag=front;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; front=front-&amp;gt;link;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; count1++;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; flag-&amp;gt;next=front-&amp;gt;link;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;%d-&amp;gt;&quot;,front-&amp;gt;data); //nodes which we have to delete&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; front=flag-&amp;gt;link;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot;\n&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printf(&quot; who is freed is:%d\n&quot;,front-&amp;gt;data);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='https://codecrow.blogspot.com/feeds/275674793512397913/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://codecrow.blogspot.com/2019/03/josephus-circle-in-data-structure-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/275674793512397913'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/275674793512397913'/><link rel='alternate' type='text/html' href='https://codecrow.blogspot.com/2019/03/josephus-circle-in-data-structure-using.html' title='Data structure Problem | Josephus Circle in Data structure using C |The easiest way you never thought'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s72-c/crow.jfif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5310694419122437967.post-2802144442340180753</id><published>2019-03-04T09:00:00.000+05:30</published><updated>2019-03-14T21:30:37.591+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Linked List"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming Problems"/><title type='text'>Easy way to solve Data structure | Implementation of circuler Linked list | create list,insert element at at first &amp; display</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s1600/crow.jfif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;213&quot; data-original-width=&quot;639&quot; height=&quot;212&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s640/crow.jfif&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;Easy way to solve Data structure | Implementation of circuler Linked list | create list,insert element at at first &amp;amp; display:&lt;/b&gt;&lt;br /&gt;
In our programming website we teach computer coding to kids and pros for free online in easy way and gives knowledge about Data structure and alogorithm in C,Java,Python&lt;br /&gt;
&amp;nbsp;and other programming languages that may help you land an online job and make your programmers day successfull.&lt;br /&gt;
&lt;br /&gt;
We use best data structure notes and best programming resources. Here goes the article,dont forget to share with your friends 😃&lt;br /&gt;
&lt;b&gt;Circuler Linked list:&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;arial&amp;quot; , &amp;quot;helvetica&amp;quot; , sans-serif;&quot;&gt;Here I include only the functions of creating list,insert an element at first &amp;amp; display the link;the code is as follows:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: yellow;&quot;&gt;//Implementation of Circuler linked list&lt;/span&gt;&lt;br /&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include&amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
struct node&lt;br /&gt;
{&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int data;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;struct node *link;&lt;br /&gt;
};&lt;br /&gt;
struct node *last;&lt;br /&gt;
void list(int a)&lt;br /&gt;
{&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;struct node *temp,*ptr;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;temp=(struct node *)malloc(sizeof(struct node));&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;temp-&amp;gt;data=a;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(last==NULL)&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;last=temp;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;temp-&amp;gt;link=last;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;temp-&amp;gt;link=last-&amp;gt;link;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;last-&amp;gt;link=temp;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;last=temp;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
}&lt;br /&gt;
void addbeg(int b)&lt;br /&gt;
{&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;struct node *temp,*ptr;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;temp=(struct node *)malloc(sizeof(struct node));&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;temp-&amp;gt;data=b;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(last==NULL)&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;last=temp;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;temp-&amp;gt;link=last;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;temp-&amp;gt;link=last-&amp;gt;link;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;last-&amp;gt;link=temp;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
}&lt;br /&gt;
void display()&lt;br /&gt;
{&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;struct node *ptr;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(last==NULL)&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;\nList is empty!\n&quot;);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;ptr=last-&amp;gt;link;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;\nList is:\n&quot;);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;while(ptr!=last)&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;%d-&amp;gt;&quot;,ptr-&amp;gt;data);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ptr=ptr-&amp;gt;link;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;%d\n&quot;,last-&amp;gt;data);&lt;br /&gt;
}&lt;br /&gt;
main()&lt;br /&gt;
{&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int item,i,ch,n;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;while(1)&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;\n1.Create list\n2.Insert at first\n3.Insert at perticuler position\n4.Display\n5.Exit\nEnter your choice\n&quot;);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;ch);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;switch(ch)&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;case 1:&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;printf(&quot;Enter number of elements:&quot;);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;n);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;for(i=0;i&amp;lt;n;i++)&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;{&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;printf(&quot;Enter the element:\n&quot;);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;item);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;list(item);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;}&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;break;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;case 2:&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;printf(&quot;Enter the element:\n&quot;);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;item);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;addbeg(item);&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;break;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;case 4:&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;display();&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;break;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;case 5:&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;exit(0);&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;
}&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='https://codecrow.blogspot.com/feeds/2802144442340180753/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://codecrow.blogspot.com/2019/03/implementation-of-circuler-linked.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/2802144442340180753'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/2802144442340180753'/><link rel='alternate' type='text/html' href='https://codecrow.blogspot.com/2019/03/implementation-of-circuler-linked.html' title='Easy way to solve Data structure | Implementation of circuler Linked list | create list,insert element at at first &amp; display'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s72-c/crow.jfif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5310694419122437967.post-161934050590202341</id><published>2019-03-03T09:00:00.000+05:30</published><updated>2019-03-14T21:31:24.945+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Programming Problems"/><category scheme="http://www.blogger.com/atom/ns#" term="Stack"/><title type='text'>Data Structure Problem | Stack implementation using Linked list | Best source of competitive coding</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s1600/crow.jfif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;213&quot; data-original-width=&quot;639&quot; height=&quot;212&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s640/crow.jfif&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;Data Structure Problem | Stack implementation using Linked list | Best source of competitive coding :&lt;/b&gt;&lt;br /&gt;
In our programming website we teach computer coding to kids and pros for free online in easy way and gives knowledge about Data structure and alogorithm in C,Java,Python&lt;br /&gt;
&amp;nbsp;and other programming languages that may help you land an online job and make your programmers day successfull.&lt;br /&gt;
&lt;br /&gt;
We use best data structure notes and best programming resources. Here goes the article,dont forget to share with your friends 😃&lt;br /&gt;
&lt;b&gt;Implementing stack using linked:&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;
A stack can be implemented with the help of the linked list &amp;amp; also with the help of the array;here we discuss about the linked list case;more precisely singly linked list;the code is as follows::::&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
// stack implementation using linked list&lt;/div&gt;
&lt;div&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;/div&gt;
&lt;div&gt;
#include&amp;lt;stdlib.h&amp;gt;&lt;/div&gt;
&lt;div&gt;
struct node&lt;/div&gt;
&lt;div&gt;
{&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int data;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;struct node *next;&lt;/div&gt;
&lt;div&gt;
};&lt;/div&gt;
&lt;div&gt;
struct node *top=NULL;&lt;/div&gt;
&lt;div&gt;
void push(int );&lt;/div&gt;
&lt;div&gt;
void pop();&lt;/div&gt;
&lt;div&gt;
void display();&lt;/div&gt;
&lt;div&gt;
main()&lt;/div&gt;
&lt;div&gt;
{&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;int ch,item;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;while(1)&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; printf(&quot;1.Push an element\n2.Pop an element\n3.Display the stack\n4.Exit\nEnter your choice:&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; scanf(&quot;%d&quot;,&amp;amp;ch);&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; switch(ch)&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; {&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;case 1:&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;Enter the element to be pushed:&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;scanf(&quot;%d&quot;,&amp;amp;item);&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;push(item);&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;break;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;case 2:&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;pop();&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt; break;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;case 3:&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;display();&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;break;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;case 4:&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;exit(0);&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; }&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
void push(int a)&lt;/div&gt;
&lt;div&gt;
{&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;struct node *temp;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;temp=(struct node *)malloc(sizeof(struct node));&lt;span style=&quot;color: lime;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;//allocating memory for the element to be pushed&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;temp-&amp;gt;data=a;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;temp-&amp;gt;next=top;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;top=temp;&lt;span style=&quot;color: #38761d;&quot;&gt; //now the pushed elemnt is the top of the stack&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
void pop()&lt;/div&gt;
&lt;div&gt;
{&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;struct node *temp;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;temp=top;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(top==NULL)&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;Stack is empty&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;temp=top;&lt;span style=&quot;color: #38761d;&quot;&gt;//temp points to top of stack=&amp;gt;1st element of linked list&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;Poped element is %d:&quot;,temp-&amp;gt;data);&lt;span style=&quot;color: #38761d;&quot;&gt; //1st element(element to be poped) is printed&lt;/span&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;top=top-&amp;gt;next;&lt;span style=&quot;color: #38761d;&quot;&gt; //now 2nd element of the stack is now the 1st element of stack&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;free(temp);&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
void display()&lt;/div&gt;
&lt;div&gt;
{&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;struct node *temp;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;temp=top;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(top==NULL)&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;stack is empty!&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;printf(&quot;Elements of stack are:\n&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;while(temp!=NULL)&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;{&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;printf(&quot;%d-&amp;gt;&quot;,temp-&amp;gt;data);&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;temp=temp-&amp;gt;next;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;printf(&quot;\n&quot;);&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='https://codecrow.blogspot.com/feeds/161934050590202341/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://codecrow.blogspot.com/2019/03/stack-implementation-using-linked-list.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/161934050590202341'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/161934050590202341'/><link rel='alternate' type='text/html' href='https://codecrow.blogspot.com/2019/03/stack-implementation-using-linked-list.html' title='Data Structure Problem | Stack implementation using Linked list | Best source of competitive coding'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s72-c/crow.jfif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5310694419122437967.post-3008555240326578858</id><published>2019-02-06T22:30:00.001+05:30</published><updated>2019-03-14T21:31:57.239+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Competitive Coding"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Linked List"/><title type='text'>Data Structure problem | Inserting a node at a particuler position of a linked list | For Competitive coding Lovers</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s1600/crow.jfif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;213&quot; data-original-width=&quot;639&quot; height=&quot;212&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s640/crow.jfif&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Data Structure problem | Inserting a node at a particuler position of a linked list | For Competitive coding Lovers Hacker Rank problem 4:&lt;/h2&gt;
&lt;div&gt;
&lt;div&gt;
In our programming website we teach computer coding to kids and pros for free online in easy way and gives knowledge about Data structure and alogorithm in C,Java,Python&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;and other programming languages that may help you land an online job and make your programmers day successfull.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
We use best data structure notes and best programming resources. Here goes the article,dont forget to share with your friends 😃&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
The code is given below:&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;background-color: #fffffe; font-family: monospace; font-size: 15px; line-height: 20px; white-space: pre;&quot;&gt;
&lt;div&gt;
&lt;span style=&quot;color: green;&quot;&gt;/ The function is given below&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: green;&quot;&gt;prerequisite:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: green;&quot;&gt;node {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: green;&quot;&gt;    int data;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: green;&quot;&gt;    node* link;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: green;&quot;&gt;};&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: green;&quot;&gt;_________________________________________________________________________________&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
node* position(node* root, &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; data, &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; pos) {&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;struct&lt;/span&gt; node  *ptr,*tmp;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; i;&lt;/div&gt;
&lt;div&gt;
tmp= (node *)malloc(&lt;span style=&quot;color: blue;&quot;&gt;sizeof&lt;/span&gt;(node ));&lt;/div&gt;
&lt;div&gt;
tmp-&amp;gt;data=data;&lt;/div&gt;
&lt;div&gt;
tmp=root;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;for&lt;/span&gt;(i=&lt;span style=&quot;color: #09885a;&quot;&gt;0&lt;/span&gt;;i&amp;lt;pos-&lt;span style=&quot;color: #09885a;&quot;&gt;1&lt;/span&gt;;i++){&lt;/div&gt;
&lt;div&gt;
ptr=ptr-&amp;gt;link;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;(ptr==NULL)&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; ;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
tmp-&amp;gt;link=ptr-&amp;gt;link;&lt;/div&gt;
&lt;div&gt;
ptr-&amp;gt;link=tmp;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; root;&lt;/div&gt;
&lt;div&gt;
}&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='https://codecrow.blogspot.com/feeds/3008555240326578858/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://codecrow.blogspot.com/2019/02/inserting-node-at-particuler-position.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/3008555240326578858'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/3008555240326578858'/><link rel='alternate' type='text/html' href='https://codecrow.blogspot.com/2019/02/inserting-node-at-particuler-position.html' title='Data Structure problem | Inserting a node at a particuler position of a linked list | For Competitive coding Lovers'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s72-c/crow.jfif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5310694419122437967.post-3175806146595103757</id><published>2019-02-06T22:30:00.000+05:30</published><updated>2019-03-14T21:32:23.621+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Competitive Coding"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Linked List"/><title type='text'>Data Structure Problem | Insert element at the tail of a linked list | A competive coding lover must check it</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s1600/crow.jfif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;213&quot; data-original-width=&quot;639&quot; height=&quot;212&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s640/crow.jfif&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Data Structure Problem | Insert element at the tail of a linked list | A competive coding lover must check it | Hacker Rank problem 2:&lt;/h2&gt;
&lt;div&gt;
&lt;div&gt;
In our programming website we teach computer coding to kids and pros for free online in easy way and gives knowledge about Data structure and alogorithm in C,Java,Python&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;and other programming languages that may help you land an online job and make your programmers day successfull.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
We use best data structure notes and best programming resources. Here goes the article,dont forget to share with your friends 😃&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;background-color: #fffffe; font-family: monospace; font-size: 15px; line-height: 20px; white-space: pre;&quot;&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
node* tail(node* root, &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; data) {&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;struct&lt;/span&gt; node *t,*p;&lt;/div&gt;
&lt;div&gt;
p= (&lt;span style=&quot;color: blue;&quot;&gt;struct&lt;/span&gt; node *)malloc(&lt;span style=&quot;color: blue;&quot;&gt;sizeof(n&lt;/span&gt;ode));//dynamically allocating memory for the node to be inserted&lt;/div&gt;
&lt;div&gt;
p-&amp;gt;data=data;//allocate the data part of the node to be inserted&lt;/div&gt;
&lt;div&gt;
p-&amp;gt;link=NULL;//because the address part of the last element of linked list is NULL&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;if&lt;/span&gt;(root==NULL){&lt;/div&gt;
&lt;div&gt;
root=p;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;else&lt;/span&gt;{&lt;/div&gt;
&lt;div&gt;
t=root;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;while&lt;/span&gt;(t-&amp;gt;link!=NULL){&lt;/div&gt;
&lt;div&gt;
t=t-&amp;gt;link;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
t-&amp;gt;link=p;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;return&lt;/span&gt; root;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='https://codecrow.blogspot.com/feeds/3175806146595103757/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://codecrow.blogspot.com/2019/02/insert-element-at-tail-of-linked-list.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/3175806146595103757'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/3175806146595103757'/><link rel='alternate' type='text/html' href='https://codecrow.blogspot.com/2019/02/insert-element-at-tail-of-linked-list.html' title='Data Structure Problem | Insert element at the tail of a linked list | A competive coding lover must check it'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s72-c/crow.jfif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5310694419122437967.post-2157301335465006377</id><published>2019-02-06T16:00:00.000+05:30</published><updated>2019-03-14T21:32:45.754+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Competitive Coding"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Linked List"/><title type='text'>Data structure Problem | Add element at the the head of a single linked list | competitive coding | HackerRank challenge</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s1600/crow.jfif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;213&quot; data-original-width=&quot;639&quot; height=&quot;212&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s640/crow.jfif&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Data structure Problem | Add element at the the head of a single linked list | competitive coding | HackerRank challenge|Hacker Rank problem 3:&lt;/h2&gt;
&lt;div&gt;
&lt;div&gt;
In our programming website we teach computer coding to kids and pros for free online in easy way and gives knowledge about Data structure and alogorithm in C,Java,Python&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;and other programming languages that may help you land an online job and make your programmers day successfull.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
We use best data structure notes and best programming resources. Here goes the article,dont forget to share with your friends 😃&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;font-family: monospace; font-size: 15px; line-height: 20px; white-space: pre;&quot;&gt;
&lt;div style=&quot;line-height: 20px;&quot;&gt;
&lt;div style=&quot;background-color: #fffffe;&quot;&gt;
node* Head(node* root, &lt;span style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; data) {&lt;/div&gt;
&lt;div style=&quot;background-color: #fffffe;&quot;&gt;
&lt;span style=&quot;color: blue;&quot;&gt;struct&lt;/span&gt; node  *r;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: #fffffe;&quot;&gt;  r = (node *)malloc(&lt;/span&gt;&lt;span style=&quot;background-color: #fffffe; color: blue;&quot;&gt;sizeof&lt;/span&gt;&lt;span style=&quot;background-color: #fffffe;&quot;&gt;(struct node ));&lt;/span&gt;&lt;span style=&quot;background-color: white; color: blue;&quot;&gt;//allocating memory for node to be inserted&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; color: blue;&quot;&gt;  r-&amp;gt;data=data;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; color: blue;&quot;&gt;  r-&amp;gt;link=root;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; color: blue;&quot;&gt;  root=r;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; color: blue;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt; root;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: #fffffe;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='https://codecrow.blogspot.com/feeds/2157301335465006377/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://codecrow.blogspot.com/2019/02/add-element-at-the-head-of-single.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/2157301335465006377'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/2157301335465006377'/><link rel='alternate' type='text/html' href='https://codecrow.blogspot.com/2019/02/add-element-at-the-head-of-single.html' title='Data structure Problem | Add element at the the head of a single linked list | competitive coding | HackerRank challenge'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s72-c/crow.jfif" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5310694419122437967.post-6265601283826544802</id><published>2019-02-05T23:43:00.002+05:30</published><updated>2019-03-14T21:33:09.926+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Competitive Coding"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure"/><category scheme="http://www.blogger.com/atom/ns#" term="Linked List"/><title type='text'>Data Structure problem | Print elements of a single Linked List | Hacker Rank Challenge | Competitive Coding lovers can&#39;t miss it</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s1600/crow.jfif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;213&quot; data-original-width=&quot;639&quot; height=&quot;212&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s640/crow.jfif&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Data Structure problem | Print elements of a single Linked List | Hacker Rank Challenge | Competitive Coding lovers can&#39;t miss it | Hacker Rank Data structure problem 1:&lt;/h2&gt;
&lt;div&gt;
&lt;div&gt;
In our programming website we teach computer coding to kids and pros for free online in easy way and gives knowledge about Data structure and alogorithm in C,Java,Python&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;and other programming languages that may help you land an online job and make your programmers day successfull.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
We use best data structure notes and best programming resources. Here goes the article,dont forget to share with your friends 😃&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
Here we just discuss about printing the element of a single linked list,this is a solution of&amp;nbsp; a problem given in &lt;b&gt;Hacker Rank.&lt;/b&gt;The code is given below:&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;background-color: #fffffe; font-family: monospace; font-size: 15px; line-height: 20px; white-space: pre;&quot;&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; print(node* root) {&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;struct n&lt;/span&gt;ode* t;//this pointer is used to travarse the list&lt;/div&gt;
&lt;div&gt;
t=root;//set the pointer to head&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;while&lt;/span&gt;(t!=NULL){&lt;/div&gt;
&lt;div&gt;
printf(&lt;span style=&quot;color: #a31515;&quot;&gt;&quot;%d\t&quot;&lt;/span&gt;,t-&amp;gt;data);//print each elements&lt;/div&gt;
&lt;div&gt;
t=t-&amp;gt;link;//going from one element to another&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='https://codecrow.blogspot.com/feeds/6265601283826544802/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://codecrow.blogspot.com/2019/02/print-elements-of-single-linked-list.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/6265601283826544802'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/5310694419122437967/posts/default/6265601283826544802'/><link rel='alternate' type='text/html' href='https://codecrow.blogspot.com/2019/02/print-elements-of-single-linked-list.html' title='Data Structure problem | Print elements of a single Linked List | Hacker Rank Challenge | Competitive Coding lovers can&#39;t miss it'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSk9wz0XRLgK7oJvQdwHbjbdhv9SerMQ70WMdpSdIezj1XOW11TCVthe0FznXnQI8sv9Xk4ZFKKPo-yi5r2W1wfgBWSRzzxtfsr39YyvYOmZ8ZCMa_U8Ugx92sbZAHGMkGFsvijU1ljqAe/s72-c/crow.jfif" height="72" width="72"/><thr:total>3</thr:total></entry></feed>