<?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-2847667723998897441</id><updated>2014-07-09T04:15:52.910-07:00</updated><title type='text'>ProgrammingProblem</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://codeingviewer.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2847667723998897441/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://codeingviewer.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>saurav nagpal</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-c4EPXk8ZoBg/AAAAAAAAAAI/AAAAAAAAAG8/gNrk-_3s0Qk/s512-c/photo.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2847667723998897441.post-2170525715732940760</id><published>2012-10-08T22:54:00.003-07:00</published><updated>2012-10-08T22:54:45.759-07:00</updated><title type='text'>Search pivot 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;p1&quot;&gt;//Solution for finding a pivot element in a rotated array.&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;typedef&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;int&lt;/span&gt; IntArray[&lt;span class=&quot;s2&quot;&gt;7&lt;/span&gt;];&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;int&lt;/span&gt; findPivot(&lt;span class=&quot;s1&quot;&gt;int&lt;/span&gt;[],&lt;span class=&quot;s1&quot;&gt;int&lt;/span&gt; low,&lt;span class=&quot;s1&quot;&gt;int&lt;/span&gt; high);&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;int&lt;/span&gt; main(&lt;span class=&quot;s1&quot;&gt;int&lt;/span&gt; argc, &lt;span class=&quot;s1&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;char&lt;/span&gt; * argv[])&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;{&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;s3&quot;&gt;IntArray&lt;/span&gt; myArr = {3,4,5,6,7,1,2};&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;s1&quot;&gt;int&lt;/span&gt; number = &lt;span class=&quot;s4&quot;&gt;findPivot&lt;/span&gt;(myArr, &lt;span class=&quot;s2&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;s2&quot;&gt;7&lt;/span&gt;);&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;s5&quot;&gt;printf&lt;/span&gt;(&lt;span class=&quot;s6&quot;&gt;&quot;%d&quot;&lt;/span&gt;,number);&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;s5&quot;&gt;getchar&lt;/span&gt;();&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;s1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;}&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;int&lt;/span&gt; findPivot(&lt;span class=&quot;s1&quot;&gt;int&lt;/span&gt; myArr[],&lt;span class=&quot;s1&quot;&gt;int&lt;/span&gt; low,&lt;span class=&quot;s1&quot;&gt;int&lt;/span&gt; high)&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;{&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;s1&quot;&gt;if&lt;/span&gt;(low &amp;lt; high)&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;s1&quot;&gt;int&lt;/span&gt; mid = (low + high) / &lt;span class=&quot;s2&quot;&gt;2&lt;/span&gt;;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;s1&quot;&gt;if&lt;/span&gt;(myArr[mid]&amp;nbsp; &amp;gt; myArr[mid +&lt;span class=&quot;s2&quot;&gt;1&lt;/span&gt;])&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;s1&quot;&gt;return&lt;/span&gt; mid;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;s1&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;if&lt;/span&gt;(myArr[mid] &amp;gt; myArr[low])&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;s1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;s4&quot;&gt;findPivot&lt;/span&gt;(myArr, mid+&lt;span class=&quot;s2&quot;&gt;1&lt;/span&gt;, high);&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;s1&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;s1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;s4&quot;&gt;findPivot&lt;/span&gt;(myArr, low, mid-&lt;span class=&quot;s2&quot;&gt;1&lt;/span&gt;);&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;s1&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;s1&quot;&gt;return&lt;/span&gt; -&lt;span class=&quot;s2&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;}&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeingviewer.blogspot.com/feeds/2170525715732940760/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeingviewer.blogspot.com/2012/10/search-pivot-element.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2847667723998897441/posts/default/2170525715732940760'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2847667723998897441/posts/default/2170525715732940760'/><link rel='alternate' type='text/html' href='http://codeingviewer.blogspot.com/2012/10/search-pivot-element.html' title='Search pivot Element '/><author><name>saurav nagpal</name><uri>https://plus.google.com/116642895992047147484</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-c4EPXk8ZoBg/AAAAAAAAAAI/AAAAAAAAAG8/gNrk-_3s0Qk/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2847667723998897441.post-8580271923949089777</id><published>2012-10-08T02:56:00.001-07:00</published><updated>2012-10-08T02:56:07.901-07:00</updated><title type='text'>Reverse a Link List</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Hello,&lt;br /&gt;&lt;br /&gt;I am publishing the code for reverse a link list by two methods:&lt;br /&gt;&lt;br /&gt;// It will simply reverse a link list using iteration.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        &lt;br /&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;void&lt;/span&gt; reverseNonRecursive(&lt;span class=&quot;s2&quot;&gt;_link_list_st&lt;/span&gt;* head)&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;{&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;s2&quot;&gt;_link_list_st&lt;/span&gt;*&amp;nbsp; prevLink = head-&amp;gt;&lt;span class=&quot;s2&quot;&gt;next_data&lt;/span&gt;;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;s2&quot;&gt;_link_list_st&lt;/span&gt;*&amp;nbsp; nextLink = prevLink-&amp;gt;&lt;span class=&quot;s2&quot;&gt;next_data&lt;/span&gt;;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; prevLink-&amp;gt;&lt;span class=&quot;s2&quot;&gt;next_data&lt;/span&gt; = &lt;span class=&quot;s1&quot;&gt;NULL&lt;/span&gt;;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;s1&quot;&gt;while&lt;/span&gt; (&lt;span class=&quot;s3&quot;&gt;1&lt;/span&gt;)&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;s2&quot;&gt;_link_list_st&lt;/span&gt;*&amp;nbsp; temp = nextLink-&amp;gt;&lt;span class=&quot;s2&quot;&gt;next_data&lt;/span&gt;;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; nextLink-&amp;gt;&lt;span class=&quot;s2&quot;&gt;next_data&lt;/span&gt; = prevLink;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; prevLink = nextLink;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; nextLink = temp;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;s1&quot;&gt;if&lt;/span&gt;(nextLink == &lt;span class=&quot;s1&quot;&gt;NULL&lt;/span&gt;)&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; head-&amp;gt;&lt;span class=&quot;s2&quot;&gt;next_data&lt;/span&gt; = prevLink;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;s1&quot;&gt;break&lt;/span&gt;;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;}&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;//It will used recursion to reverse a link list.&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;// To call this method we need &amp;nbsp;&quot;reverseRecursive&lt;span class=&quot;s1&quot;&gt;(head,&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;NULL&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;);&quot;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&lt;span class=&quot;s1&quot;&gt;void&lt;/span&gt; reverseRecursive(&lt;span class=&quot;s2&quot;&gt;_link_list_st&lt;/span&gt;* ptr,&lt;span class=&quot;s2&quot;&gt;_link_list_st&lt;/span&gt;* prev)&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;{&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;s1&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;_link_list_st&lt;/span&gt;* link_head = &lt;span class=&quot;s1&quot;&gt;NULL&lt;/span&gt;;&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;s1&quot;&gt;if&lt;/span&gt;(prev == &lt;span class=&quot;s1&quot;&gt;NULL&lt;/span&gt;)&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; link_head = ptr;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ptr = link_head-&amp;gt;&lt;span class=&quot;s2&quot;&gt;next_data&lt;/span&gt;;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;s1&quot;&gt;if&lt;/span&gt;(ptr == &lt;span class=&quot;s1&quot;&gt;NULL&lt;/span&gt;)&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; link_head-&amp;gt;&lt;span class=&quot;s2&quot;&gt;next_data&lt;/span&gt; = prev;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;s1&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; {&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;s4&quot;&gt;reverseRecursive&lt;/span&gt;(ptr-&amp;gt;&lt;span class=&quot;s2&quot;&gt;next_data&lt;/span&gt;,ptr);&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ptr-&amp;gt;&lt;span class=&quot;s2&quot;&gt;next_data&lt;/span&gt; = prev;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div class=&quot;p2&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/div&gt;&lt;div class=&quot;p1&quot;&gt;}&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codeingviewer.blogspot.com/feeds/8580271923949089777/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codeingviewer.blogspot.com/2012/10/reverse-link-list.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2847667723998897441/posts/default/8580271923949089777'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2847667723998897441/posts/default/8580271923949089777'/><link rel='alternate' type='text/html' href='http://codeingviewer.blogspot.com/2012/10/reverse-link-list.html' title='Reverse a Link List'/><author><name>saurav nagpal</name><uri>https://plus.google.com/116642895992047147484</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-c4EPXk8ZoBg/AAAAAAAAAAI/AAAAAAAAAG8/gNrk-_3s0Qk/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry></feed>