<?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: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-1054067205364967531</id><updated>2011-12-31T13:39:06.526+05:30</updated><category term='2D array'/><category term='Data Structures'/><category term='Mathematics'/><category term='Interview'/><category term='tips'/><category term='Operating Systems'/><title type='text'>Ashes To Glory</title><subtitle type='html'>Burning Desire - Determination - Vision</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://rajendrauppal.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://rajendrauppal.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Rajendra Kumar Uppal</name><uri>http://www.blogger.com/profile/08197834521620905502</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_pBounEjPPcY/SLpMsEJb4_I/AAAAAAAAAAU/ewlBl-0W6R0/S220/in+Gtalk+(copy).JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>16</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1054067205364967531.post-3916936333076938749</id><published>2011-12-02T01:31:00.000+05:30</published><updated>2011-12-28T11:01:42.163+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Interview'/><category scheme='http://www.blogger.com/atom/ns#' term='2D array'/><category scheme='http://www.blogger.com/atom/ns#' term='Data Structures'/><category scheme='http://www.blogger.com/atom/ns#' term='Mathematics'/><title type='text'>Rotating a 2D array of integers (matrix) by a given angle (+90, -90, +180, -180)</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;So, I came across this problem on a forum and before looking up, I tried to solve it. After 15 minutes of trying, I figured out that the solution is pretty easy and elegant which was messy otherwise if you are going to do it in an insane way. So, here we go:&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;b&gt;&lt;span style="color: #990000;"&gt;Problem definition:&lt;/span&gt;&lt;/b&gt; You are given a 2D square matrix, or 2D array of integers of size n (n rows and n columns), your output should be n by n 2D matrix rotated by a given angle, which could be +90, -90, +180, -180.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;i&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;Example:&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;Input &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;Output&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;1 2 3 &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 4 1&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;4 5 6 &amp;nbsp; &amp;nbsp; Rotate by +90 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8 5 2&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;7 8 9 &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;9 6 3&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;If you go by solving it something like manually, swapping elements, its going to be messy,&amp;nbsp;tedious, and error prone in that there will be much more edge cases, test cases to handle. So, after trying on paper, I figured out following elegant solution to solve this in an easy manner.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;&lt;span style="color: #990000; font-family: Verdana, sans-serif;"&gt;Rotate by +90 (clockwise once):&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;Input: n by n matrix M, where n &amp;gt;= 2&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;Algorithm:&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;i&gt;Step 1:&lt;/i&gt; &lt;a href="http://en.wikipedia.org/wiki/Transpose"&gt;Transpose&lt;/a&gt; M&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;i&gt;Step 2:&lt;/i&gt; Reverse each row&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;Dry run:&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;i&gt;Step 1:&lt;/i&gt;&amp;nbsp;Transpose&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;M &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; M'&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;1 2 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 4 7&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;4 5 6 &amp;nbsp; &amp;nbsp; &amp;nbsp;-- &amp;nbsp; &amp;nbsp; 2 5 8&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;7 8 9 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3 6 9&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;i&gt;Step 2:&lt;/i&gt; Reverse each row&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;M' &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;M''&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;1 4 7 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7 4 1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;2 5 8 &amp;nbsp; &amp;nbsp; &amp;nbsp;-- &amp;nbsp; &amp;nbsp; 8 5 2&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;3 6 9 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9 6 3&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;M'' is rotated form of M by +90 degree.&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;b&gt;Pseudocode: &lt;/b&gt;is here which is self explanatory and easily convertible to source code in a language of your choice.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;Transpose&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&amp;nbsp; &amp;nbsp; for i in [0, n)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for j in [0, n)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ( i &amp;lt; j )&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; swap( M[i][j], M[j][i] )&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;Reverse a row (rowidx)&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&amp;nbsp; &amp;nbsp; start = 0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&amp;nbsp; &amp;nbsp; end = cols - 1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&amp;nbsp; &amp;nbsp; while ( start &amp;lt; end ) {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; swap( M[rowidx][start], M[rowidx][end] )&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ++start&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; --end&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;Rotate&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&amp;nbsp; &amp;nbsp; Transpose&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&amp;nbsp; &amp;nbsp; for i in [0, rows)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Reverse( i )&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;That was fair enough until only asked to rotate by +90 degree. If problem is further extended to be solved for &lt;b&gt;any given angle&lt;/b&gt;, of course the rotation should make sense, for example, 47 degree is not a choice ;-). So, here are some elegant techniques (I'll be brief now for other angles, because for +90 degree I have elaborated the solution):&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;&lt;span style="color: #990000; font-family: Verdana, sans-serif;"&gt;Rotation by -90 degree (anticlockwise once):&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;i&gt;Step 1&lt;/i&gt;: Transpose&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;i&gt;Step 2&lt;/i&gt;: Reverse each column&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;b&gt;&lt;span style="color: #990000;"&gt;Rotation by +180 degree (clockwise twice):&lt;/span&gt;&amp;nbsp;&lt;/b&gt;Two methods follows&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;First:&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;Rotate input matrix +90 degree twice, if routine for which is available to you&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;b&gt;Second:&lt;/b&gt; (You'll be amazed!)&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;Step 1: Reverse each row&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;Step 2: Reverse each column&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;b&gt;&lt;span style="color: #990000;"&gt;Rotation by -180 degree (anticlockwise twice):&lt;/span&gt;&lt;/b&gt; Three(!!!) methods follows&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;First:&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;Rotate input matrix -90 degree twice, if routine for which is available to you&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;b&gt;Second:&lt;/b&gt; (You'll be amazed again!)&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;Step 1: Reverse each column&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;Step 2: Reverse each row&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;b&gt;Third:&lt;/b&gt; (Aha!)&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;Because rotating a matrix +180 degree or -180 should produce same result. So you can rotate it by +180 degree using one of above methods.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;b&gt;&lt;span style="color: #990000;"&gt;Concluding note:&lt;/span&gt;&lt;/b&gt; Above techniques are elegant and very simple and straightforward to implement. Try them for some input of your choice and rotate it in all angles. These techniques are tested with a working C program.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;Cheers!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;Rajendra&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br class="Apple-interchange-newline" /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-family: Verdana, sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1054067205364967531-3916936333076938749?l=rajendrauppal.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rajendrauppal.blogspot.com/feeds/3916936333076938749/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1054067205364967531&amp;postID=3916936333076938749' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/3916936333076938749'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/3916936333076938749'/><link rel='alternate' type='text/html' href='http://rajendrauppal.blogspot.com/2011/12/rotating-2d-array-of-integers-matrix-by.html' title='Rotating a 2D array of integers (matrix) by a given angle (+90, -90, +180, -180)'/><author><name>Rajendra Kumar Uppal</name><uri>http://www.blogger.com/profile/08197834521620905502</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_pBounEjPPcY/SLpMsEJb4_I/AAAAAAAAAAU/ewlBl-0W6R0/S220/in+Gtalk+(copy).JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1054067205364967531.post-1907906525496903224</id><published>2011-11-04T10:30:00.001+05:30</published><updated>2011-11-04T12:30:08.859+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Operating Systems'/><category scheme='http://www.blogger.com/atom/ns#' term='Data Structures'/><title type='text'>Use of Data Structures in Operating Systems</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Computer science students generally study data structures, both those on the main topic of a full course and as portions of many upper level courses, such as compilers, databases, networking and operating systems.&amp;nbsp;Data structures are used abundantly in operating systems.&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Queues&lt;/b&gt; - are used wherever entities need to wait, e.g., processes waiting for a processor, I/O requests are waiting for devices to become available, processes waiting for access to their critical sections and so on.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Stacks&lt;/b&gt; - are used for supporting the function call return mechanism.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Trees&lt;/b&gt; - are used to represent file system directory structures, to keep track of the allocation of disk space to files, to build hierarchical page directory structures in support of virtual address translation and so on.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Graphs&lt;/b&gt; - are used when studying networking.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Hash Tables&lt;/b&gt; - are used when implementing Process tables to access a process's control block (PCB) quickly, using PID (process identification number) as the key.&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Cheers!&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Rajendra&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1054067205364967531-1907906525496903224?l=rajendrauppal.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rajendrauppal.blogspot.com/feeds/1907906525496903224/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1054067205364967531&amp;postID=1907906525496903224' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/1907906525496903224'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/1907906525496903224'/><link rel='alternate' type='text/html' href='http://rajendrauppal.blogspot.com/2011/11/use-of-data-structures-in-operating.html' title='Use of Data Structures in Operating Systems'/><author><name>Rajendra Kumar Uppal</name><uri>http://www.blogger.com/profile/08197834521620905502</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_pBounEjPPcY/SLpMsEJb4_I/AAAAAAAAAAU/ewlBl-0W6R0/S220/in+Gtalk+(copy).JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1054067205364967531.post-3835351849889101848</id><published>2011-10-30T13:56:00.000+05:30</published><updated>2011-10-31T21:18:38.799+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='Interview'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><title type='text'>Strategies For A Great Interview</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div style="text-align: justify;"&gt;&lt;/div&gt;&lt;div style="display: inline !important;"&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="display: inline !important;"&gt;A typical one hour interview with a single interviewer consists of five&amp;nbsp;minutes of introductions and questions about the candidate's resume. This&amp;nbsp;is followed by five to fifteen minutes of questioning on basic programming concepts.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;The core of the interview is one or two detailed algorithm design&amp;nbsp;questions where the candidate is expected to present a detailed solution on&amp;nbsp;a whiteboard or paper. Depending on the interviewer and the question,&amp;nbsp;the &amp;nbsp;solution may be required to include syntactically correct code in&amp;nbsp;a language that the candidate is comfortable with.&amp;nbsp;The reason for asking such question's is that algorithms and associated&amp;nbsp;data-structures underlie all &amp;nbsp;software. They are often hidden in library&amp;nbsp;calls. They can be a small part of a code base dominated by I/O&amp;nbsp;and format conversion. But they are the crucial component in terms of&amp;nbsp;performance and intricacy.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;The most important part of interview preparation is to know the material&amp;nbsp;and practice solving problems. However the non-technical aspects&amp;nbsp;of interviewing cannot be underplayed either. There are a number of&amp;nbsp;things that could go wrong in an interview and it is important to have a&amp;nbsp;strategy to deal with them.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;1. Before the Interview&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;One of the best ways of preparing for an interview is mock interviews.&amp;nbsp;Get a friend to ask you question's&amp;nbsp;and have you solve the problems on a whiteboard or paper. Ask your&amp;nbsp;friend to take notes and give you detailed feedback, both positive and&amp;nbsp;negative. Also ask your friend to provide hints from the solution if you&amp;nbsp;are stuck. This will help you overcome any fear or problem areas well in&amp;nbsp;advance.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;2. Approaching the Problem&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;No matter how well prepared you are, there is a good chance that the solution&amp;nbsp;to an interview problem will not occur to you immediately. When&amp;nbsp;this happens, there are several things you can do.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Clarify the question:&lt;/b&gt; This may seem obvious but it's amazing how&amp;nbsp;many interviews go badly because the candidate spends most of the time&amp;nbsp;trying to solve the wrong problem. If a question seems exceptionally&amp;nbsp;hard, there is a good chance you have misunderstood the question. The best way to clarifying the question is to state a concrete instance&amp;nbsp;of the problem. For example: if the question is "find the first occurrence of&amp;nbsp;a number greater than k in a sorted array", you could ask the following:&amp;nbsp;the input array is [2,20,30] and k is 3, then are you supposed to return 1 (index&amp;nbsp;of 20)?"&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Work on small examples:&lt;/b&gt;&amp;nbsp;This may not be true for&amp;nbsp;all the problems. However there is a large class of problems where after&amp;nbsp;working out the solution for a few small examples! you may see a pattern&amp;nbsp;emerge.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Spell out the brute-force solution:&lt;/b&gt; Problems that are put to you in an&amp;nbsp;interview tend to have an obvious brute-force solution that has a large&amp;nbsp;runtime compared to more sophisticated solutions. For example! instead&lt;/div&gt;&lt;div style="text-align: justify;"&gt;of trying to work out a dynamic programming solution for a problem,&amp;nbsp;try all the possible configurations. There are several&amp;nbsp;advantages to this: (1.) it helps you explore opportunities for optimization&amp;nbsp;and hence reach a better solution! (2.) it gives you an opportunity&amp;nbsp;to demonstrate some problem solving and coding skills! and (3.) it&amp;nbsp;establishes that both you and the interviewer are thinking about the same&amp;nbsp;problem. Be warned that this strategy can sometimes be detrimental if it&amp;nbsp;takes too long to describe even the brute-force approach and leaves you&amp;nbsp;with less time to work on the optimal solution.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Think out loud:&lt;/b&gt; One of the worst things you can do in an interview is&amp;nbsp;to freeze up while solving the &amp;nbsp;problem. It is always a good idea to think&amp;nbsp;out loud while searching for a solution. On one hand! this increases the&amp;nbsp;chances of you finding the right solution because it forces you to put&amp;nbsp;your thoughts in a coherent manner. On the other hand, it helps the interviewer guide your thought process in the right direction. In the very least, even if you are not able to reach the solution, this leaves the interviewer with the impression that you have the intellectual ability to attack an unknown problem.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Search for isomorphic problems:&lt;/b&gt; Even if you may not have seen the&amp;nbsp;exact problem, you may have seen another problem with similar mathematical&amp;nbsp;structure. See if this seems like a good fit for general algorithmic&lt;/div&gt;&lt;div style="text-align: justify;"&gt;techniques, such as, divide-and-conquer, dynamic programming,&amp;nbsp;greedy,&amp;nbsp;etc.. Can you map the problem to a graph? Can you map it to&amp;nbsp;an objective function and a set of constraints, such as an integer linear&amp;nbsp;program?&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;3. Presenting the Solution&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Once you have a solution, it is important to present it well and do a comprehensive&amp;nbsp;job at it. A lot of these things become simpler if you use a&amp;nbsp;higher level language such as Java. However you should use the language&lt;/div&gt;&lt;div style="text-align: justify;"&gt;with which you are most familiar. In most scenarios, it is perfectly&amp;nbsp;fine to write a pseudo-code as well. Here are some thoughts that could&amp;nbsp;help:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Test for corner cases:&lt;/b&gt; For a number of problems, your general idea&amp;nbsp;may work for the majority of the cases but there may be a few obscure&amp;nbsp;inputs where your algorithm (or code) would fail. For example, you&lt;/div&gt;&lt;div style="text-align: justify;"&gt;could write a binary search code that crashes if the input is an empty&amp;nbsp;array or you may do arithmetic without considering the possibility of&amp;nbsp;integer overflow. It is important to check for these things carefully. One&amp;nbsp;way of doing this is to construct a few test cases and work out the output&amp;nbsp;of your algorithm for them. In many cases, the code to handle some&amp;nbsp;obscure corner cases may be too complicated. In such cases, you should&amp;nbsp;at least mention to the interviewer that you are aware of the problem and&amp;nbsp;you could try to address it if they are interested.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Function signature:&lt;/b&gt; Several candidates tend to get this wrong and&amp;nbsp;getting your function signature wrong reflects badly on you. For example,&amp;nbsp;it would be bad if you are writing the code in C language and&amp;nbsp;your function returns an array but you fail to return the size of the array&amp;nbsp;along with the pointer. Another place where function signatures could&amp;nbsp;be important is knowing when to pass parameters by value versus by&amp;nbsp;reference.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Memory management:&lt;/b&gt; If you allocate memory in your function, you&amp;nbsp;must ensure that in every execution path, this memory is de-allocated. In&amp;nbsp;general, it is best to avoid memory management operations all together. If you must do this, consider use of scoped pointers.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;Syntax:&lt;/b&gt; In almost all cases, the interviewers are not evaluating you&amp;nbsp;on the correctness of the syntax of your code. The editors and compilers&amp;nbsp;do a great job at helping you get the syntax right. However you cannot&amp;nbsp;underplay the possibility of an interviewer leaving with the impression&amp;nbsp;that you got most of the syntax wrong since you do not have much experience writing code. Hence once you are done writing your code, you should make a pass over it to avoid any obvious syntax errors before&amp;nbsp;claiming you are done.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;4. Know your Interviewers&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;If the organization can share some information about the background of&amp;nbsp;your interviewers, it can help you a great deal. For fresh graduates, it is&amp;nbsp;also important to think .from the perspective of the interviewers. It is also important to note that once you ace the interview, you will&amp;nbsp;have an offer and you would have an important decision to make: is&amp;nbsp;this the organization where you want to work? Interviews are the best&amp;nbsp;time to collect this information. Based on your interaction with the interviewers,&amp;nbsp;you can get a pretty good idea of their intellect as well as&amp;nbsp;how pleasant the organization could be. Most interviews end with the&amp;nbsp;interviewers letting the candidates ask questions. You should make the&amp;nbsp;best use of this time by &lt;b&gt;(1.)&lt;/b&gt; getting the information you would need and&amp;nbsp;&lt;b&gt;(2.)&lt;/b&gt; communicating to the interviewer that you are interested in the job.&amp;nbsp;Prepare a list of questions in advance that both gets you helpful information&amp;nbsp;as well as shows your knowledge and interest in the organization.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;5. General Conversation&lt;/b&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Often interviewers will spend some time asking questions about your&amp;nbsp;past projects, dissertation,&amp;nbsp;etc.. The point of this conversation is:&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;&amp;nbsp;- Can the candidate clearly communicate a complex idea:&lt;/b&gt; This is one&amp;nbsp;of the most important skills for working in an engineering team. If you&amp;nbsp;have a grand idea to redesign a big system, can you communicate it to&lt;/div&gt;&lt;div style="text-align: justify;"&gt;your colleagues and bring them on board? It is best to practice how you&amp;nbsp;want to present some of your best work in advance. Being precise, clear,&amp;nbsp;and having concrete examples can go a long way here. For candidates&amp;nbsp;who have to communicate in a language that is not their first language,&amp;nbsp;it may be important to speak slowly and perhaps use the whiteboard to&amp;nbsp;augment their words.&amp;nbsp;Is the candidate passionate about his work: We always want our&amp;nbsp;colleagues to be passionate, full of energy, and inspiring to work with.&amp;nbsp;If you are so passionate about your work that your eyes light up while&amp;nbsp;describing your work, it can go a long way in terms of establishing you&amp;nbsp;as a great colleague. Hence when you are asked to describe a project&amp;nbsp;from the past, it is best to pick something that you are passionate about&amp;nbsp;rather than a project that was complex but did not interest you.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;b&gt;&amp;nbsp;- Is there a potential interest match with some project:&lt;/b&gt; During a general&amp;nbsp;conversation, the interviewer may gauge areas of strengths for a potential&amp;nbsp;project match. If you know the requirements of the job, you may want to steer the conversation in that direction. However in the computing&amp;nbsp;industry, things change so fast that most teams prefer a strong&amp;nbsp;generalist.&amp;nbsp;Also, it is a good idea to maintain a homepage with links to your&amp;nbsp;projects and articles; things that can help interviewers learn more about&amp;nbsp;you.&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Cheers!&amp;nbsp;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Rajendra&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1054067205364967531-3835351849889101848?l=rajendrauppal.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rajendrauppal.blogspot.com/feeds/3835351849889101848/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1054067205364967531&amp;postID=3835351849889101848' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/3835351849889101848'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/3835351849889101848'/><link rel='alternate' type='text/html' href='http://rajendrauppal.blogspot.com/2011/10/strategies-for-great-interview.html' title='Strategies For A Great Interview'/><author><name>Rajendra Kumar Uppal</name><uri>http://www.blogger.com/profile/08197834521620905502</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_pBounEjPPcY/SLpMsEJb4_I/AAAAAAAAAAU/ewlBl-0W6R0/S220/in+Gtalk+(copy).JPG'/></author><thr:total>2</thr:total><georss:featurename>Bengaluru, Karnataka, India</georss:featurename><georss:point>12.9715987 77.5945627</georss:point><georss:box>12.724026199999999 77.2787057 13.2191712 77.91041969999999</georss:box></entry><entry><id>tag:blogger.com,1999:blog-1054067205364967531.post-1531426092858394568</id><published>2011-10-29T10:58:00.000+05:30</published><updated>2011-10-29T10:58:37.726+05:30</updated><title type='text'>Multi-tasking vs Multi-threading vs Multi-processing</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;b&gt;Multi-tasking&lt;/b&gt; - Illusion of being able to do more than one thing at a time.&lt;br /&gt;&lt;b&gt;Multi-threading&lt;/b&gt; - Illusion of being able to do more than one thing at a time within a thing.&lt;br /&gt;&lt;b&gt;Multi-processing&lt;/b&gt; - Really being able to do more than one thing at a time.&lt;br /&gt;&lt;br /&gt;Cheers!&lt;br /&gt;Rajendra&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1054067205364967531-1531426092858394568?l=rajendrauppal.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rajendrauppal.blogspot.com/feeds/1531426092858394568/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1054067205364967531&amp;postID=1531426092858394568' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/1531426092858394568'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/1531426092858394568'/><link rel='alternate' type='text/html' href='http://rajendrauppal.blogspot.com/2011/10/multi-tasking-vs-multi-threading-vs.html' title='Multi-tasking vs Multi-threading vs Multi-processing'/><author><name>Rajendra Kumar Uppal</name><uri>http://www.blogger.com/profile/08197834521620905502</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_pBounEjPPcY/SLpMsEJb4_I/AAAAAAAAAAU/ewlBl-0W6R0/S220/in+Gtalk+(copy).JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1054067205364967531.post-2414188753384029826</id><published>2011-01-11T12:12:00.003+05:30</published><updated>2011-02-13T20:34:45.740+05:30</updated><title type='text'>Number To Words Algorithm</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Number&amp;nbsp;To Words Algorithm&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Problem: Given any number of maximum 15 digits number convert it to a&amp;nbsp;string which represents this number in words.&lt;br /&gt;e.g., Input: 231 Output: Two Hundred And Thirty One.&lt;br /&gt;&lt;br /&gt;1. Input example: &lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;34541009234120&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Find length of input string of digits, if it's a multiple of 3 then do nothing else pad with leading&amp;nbsp;zero's&amp;nbsp;to make it's length an exact multiple of 3 and divide the input number&amp;nbsp;into 5 groups of 3 digits each, so our example input becomes&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;                        &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;034 541 009 234 120&lt;/span&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; Group No.&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; 5 &amp;nbsp; 4 &amp;nbsp; 3 &amp;nbsp; 2 &amp;nbsp; 1&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;2. Find group of most siginificant digit, e.g., here MSD is 0 and it's group&amp;nbsp;is:&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;groupNum = length%3 ? (length/3+1) : (length/3);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;3. One loop for number of groups of 3 digits each;&lt;br /&gt;&lt;br /&gt;4. One loop for each of the 3 digits inside a given group, so the time complexity&amp;nbsp;boils down to linear;&lt;br /&gt;&lt;br /&gt;5. Inside inner loop, for any given 3 digits generate a string like for e.g., 541&amp;nbsp;becomes "Five Hundred And Forty One";&lt;br /&gt;&lt;br /&gt;6. Now decide which string would come after this according to the group number&amp;nbsp;e.g., here group of 541 is 4 so "Billion" (from D array given above) would be&amp;nbsp;appended to the string generated in step 5;&lt;br /&gt;&lt;br /&gt;7. When outer loop finishes, return the string generated for the whole number.&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;e.g., "Thirty Four Trillion Five Hundred And Forty One Billion Nine Million&amp;nbsp;Two Hundred And Thirty Four &amp;nbsp;Thousand One Hundred And Twenty"&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Limitations:&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; 1. This algorithm generates words according to US number to words system.&lt;br /&gt;&amp;nbsp;&amp;nbsp; 2. It generates words from numbers till 999 trillion 999 billion 999 million&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;999 thousand and 999&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Source code (C++):&lt;/b&gt;&amp;nbsp;&amp;nbsp;Available on request.&lt;br /&gt;&amp;nbsp;&amp;nbsp; Post a comment to mention your email ID. You would receive the source code as&lt;br /&gt;&amp;nbsp;&amp;nbsp; soon as I get the request.&lt;br /&gt;&lt;br /&gt;&lt;b&gt; Cheers!&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Rajendra &lt;/b&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1054067205364967531-2414188753384029826?l=rajendrauppal.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rajendrauppal.blogspot.com/feeds/2414188753384029826/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1054067205364967531&amp;postID=2414188753384029826' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/2414188753384029826'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/2414188753384029826'/><link rel='alternate' type='text/html' href='http://rajendrauppal.blogspot.com/2011/01/number-to-words-algorithm.html' title='Number To Words Algorithm'/><author><name>Rajendra Kumar Uppal</name><uri>http://www.blogger.com/profile/08197834521620905502</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_pBounEjPPcY/SLpMsEJb4_I/AAAAAAAAAAU/ewlBl-0W6R0/S220/in+Gtalk+(copy).JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1054067205364967531.post-3030254879252485388</id><published>2011-01-11T10:57:00.002+05:30</published><updated>2011-01-11T10:57:38.203+05:30</updated><title type='text'>A lightweight Image Processing Library in C++</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: 'Times New Roman', serif; font-size: 16px; line-height: 18px;"&gt;Ever wondered how to work with/on images with little or no development overhead on your own? Here is the answer, the CImg image processing library. CImg stands for Cool Image; it is an open source, written entirely in C++, image processing toolkit which is very easy to use, handy for image processing tasks.&lt;/span&gt;&lt;br /&gt;&lt;div class="MsoNormal" style="text-align: left;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman', serif; font-size: 16px; line-height: 18px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: left;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;I first encountered this library when I was working on the dissertation, I had to extract frames from a video which I did easily using mpeg2encode and mpeg2decode, after that I had to read these frames (images) into 2D arrays and process them. I started looking for a way to achieve this and ended up with CImg library.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: left;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;CImg is designed with following properties in mind:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: left;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: left;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;&lt;b&gt;Usefulness:&lt;/b&gt;&lt;/span&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt; &lt;tt&gt;&lt;i&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; line-height: 115%;"&gt;CImg&lt;/span&gt;&lt;/i&gt;&lt;/tt&gt;&lt;span class="apple-converted-space"&gt;&lt;span style="color: black;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;span style="color: black;"&gt;defines&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span style="color: black;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;i&gt;&lt;span style="color: black;"&gt;classes&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span style="color: black;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;span style="color: black;"&gt;and&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span style="color: black;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;i&gt;&lt;span style="color: black;"&gt;methods&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span style="color: black;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;span style="color: black;"&gt;to manage images in your own C++ code. You can use it to load/save various file formats, access pixel values, display/transform/filter images, draw primitives (text, faces, curves, 3d objects, ...), compute statistics, manage user interactions on images, and so on...&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: left;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;&lt;span class="apple-style-span"&gt;&lt;span style="color: black;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: left;"&gt;&lt;tt&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;&lt;b&gt;Genericity:&lt;/b&gt;&lt;/span&gt;&lt;/tt&gt;&lt;tt&gt;&lt;i&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt; CImg&lt;/span&gt;&lt;/i&gt;&lt;/tt&gt;&lt;span class="apple-converted-space"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;defines a single image class which can represent datasets having up to&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;i&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;4-dimensions&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;(from 1d scalar signals to 3d hyperspectral volumetric images), with&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;i&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;template pixel types&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;bool,char,int,float,...&lt;/span&gt;&lt;/tt&gt;&lt;span class="apple-style-span"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;). It also handles image&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;i&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;collections&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;and&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;i&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;sequences&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: left;"&gt;&lt;span class="apple-style-span"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: left;"&gt;&lt;tt&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;&lt;b&gt;Portability:&lt;/b&gt; &lt;/span&gt;&lt;/tt&gt;&lt;span class="apple-style-span"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;CImg is self-contained and thus highly portable. It fully works on different operating systems (UNIX, Windows, MacOS X, BSD, …) and is compatible with various C++ compilers (VC++, g++, …).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: left;"&gt;&lt;span class="apple-style-span"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: left;"&gt;&lt;tt&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;&lt;b&gt;Simplicity:&lt;/b&gt;&lt;/span&gt;&lt;/tt&gt;&lt;tt&gt;&lt;i&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt; CImg&lt;/span&gt;&lt;/i&gt;&lt;/tt&gt;&lt;span class="apple-converted-space"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;is&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;i&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;lightweight&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;. It is made of a single header file&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;“CImg.h” that must be included in your C++ source. It defines only&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;i&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;four&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;different classes, encapsulated in a namespace. It can be compiled using a minimal set of standard C++ and system libraries.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: left;"&gt;&lt;span class="apple-style-span"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="text-align: left;"&gt;&lt;span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"&gt;Just include a single header file in your application or library and you done and fully equipped with amazing capability of this library.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; text-align: left;"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; text-align: left;"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;&lt;b&gt;How to use CImg in your C++ program?&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; text-align: left;"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;You just need to add these two lines in your C++ source code, in order to be able to work with CImg images:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; text-align: left;"&gt;&lt;span style="color: black; font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;#include “CImg.h”&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; text-align: left;"&gt;&lt;span style="color: black; font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;using namespace cimg_library;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: black; font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="line-height: normal; text-align: left;"&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;I guess this is enough introduction, believe me; you have to use it to realize its power and usefulness.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt;"&gt;&lt;i&gt;Reference:&lt;/i&gt; http://cimg.sourceforge.net&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;Cheers!&lt;br /&gt;Rajendra &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1054067205364967531-3030254879252485388?l=rajendrauppal.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rajendrauppal.blogspot.com/feeds/3030254879252485388/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1054067205364967531&amp;postID=3030254879252485388' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/3030254879252485388'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/3030254879252485388'/><link rel='alternate' type='text/html' href='http://rajendrauppal.blogspot.com/2011/01/lightweight-image-processing-library-in.html' title='A lightweight Image Processing Library in C++'/><author><name>Rajendra Kumar Uppal</name><uri>http://www.blogger.com/profile/08197834521620905502</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_pBounEjPPcY/SLpMsEJb4_I/AAAAAAAAAAU/ewlBl-0W6R0/S220/in+Gtalk+(copy).JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1054067205364967531.post-6979694739740438143</id><published>2010-02-27T09:31:00.003+05:30</published><updated>2010-02-27T09:40:32.119+05:30</updated><title type='text'>External linkage vs. internal linkage in C++</title><content type='html'>A global variable has external linkage by default. Its scope can be extended to files other than containing it by giving a matching extern declaration in the other file.&lt;br /&gt;The scope of a global variable can be restricted to the file containing its declaration by prefixing the declaration with the keyword static. Such variables are said to have internal linkage.&lt;br /&gt;Consider following example:&lt;br /&gt;&lt;span class="fullpost"&gt;&lt;br /&gt;&lt;b&gt;1.cpp&lt;/b&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;void f(int i);&lt;br /&gt;extern const int max = 10;&lt;br /&gt;int n = 0;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;    int a;&lt;br /&gt;    //...&lt;br /&gt;    f(a);&lt;br /&gt;    //...&lt;br /&gt;    f(a);&lt;br /&gt;    //...&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;The signature of function f declares f as a function with external linkage(default). Its definition must be provided later in this file or in other translation unit (given below).&lt;br /&gt;max is defined as an integer constant. The default linkage for constants is internal. So that max can be accessed in other files. Its linkage is made external with the keyword extern.&lt;br /&gt;n is defined as an integer variable. The default linkage for variables defined outside function bodies is external.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2.cpp&lt;/b&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;#include "iostream" // make it angle brackets!&lt;br /&gt;using namespace std;&lt;br /&gt;&lt;br /&gt;extern const int max;&lt;br /&gt;extern int n;&lt;br /&gt;static float z = 0.0;&lt;br /&gt;&lt;br /&gt;void f(int i)&lt;br /&gt;{&lt;br /&gt;    static int nCall = 0;&lt;br /&gt;    int a;&lt;br /&gt;    //...&lt;br /&gt;    nCall++;&lt;br /&gt;    n++;&lt;br /&gt;    //...&lt;br /&gt;    a = max * z;&lt;br /&gt;    //...&lt;br /&gt;    cout &amp;lt;&amp;lt; "f() called " &amp;lt;&amp;lt; nCall &amp;lt;&amp;lt; " times." &amp;lt;&amp;lt; endl;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;max is declared to have external linkage. A matching definition for max(with external linkage) must appear in some file. (As in 1.cpp)&lt;br /&gt;n is declared to have external linkage.&lt;br /&gt;z is defined as a global variable with internal linkage.&lt;br /&gt;The definition of nCall specifies nCall to be a variable that retains its value across calls to function f(). Unlike local variables with the default auto storage class, nCall will be initialized only once at the start of the program and not once for each invocation of f(). The storage class specifier static affects the lifetime of the local variable and not its scope.&lt;br /&gt;&lt;br /&gt;NB: The keyword static plays a double role. When used in the definitions of global variables, it specifies internal linkage. When used in the definitions of the local variables, it specifies that the lifetime of the variable is going to be the duration of the program instead of being the duration of the function.&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1054067205364967531-6979694739740438143?l=rajendrauppal.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rajendrauppal.blogspot.com/feeds/6979694739740438143/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1054067205364967531&amp;postID=6979694739740438143' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/6979694739740438143'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/6979694739740438143'/><link rel='alternate' type='text/html' href='http://rajendrauppal.blogspot.com/2010/02/external-linkage-vs-internal-linkage-in.html' title='External linkage vs. internal linkage in C++'/><author><name>Rajendra Kumar Uppal</name><uri>http://www.blogger.com/profile/08197834521620905502</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_pBounEjPPcY/SLpMsEJb4_I/AAAAAAAAAAU/ewlBl-0W6R0/S220/in+Gtalk+(copy).JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1054067205364967531.post-4869406536206021585</id><published>2010-01-01T21:55:00.006+05:30</published><updated>2010-01-01T22:11:07.518+05:30</updated><title type='text'>What a date!? 1.1.2010</title><content type='html'>&lt;div style="text-align: justify;"&gt;Hi, yesterday night, 31 Dec. 2009, 01:00am, I was thinking that let's see if there is something special about the new year date 1.1.2010, and after figuring out some very common observations, I found out at 09:14pm, on 1.1.2010 that the number 112010 (hundred and twelve thousand ten) is a sum of two primes which are 111997 and 13!!.&amp;nbsp; What's big deal! Clearly not. But it is.&lt;br /&gt;&lt;/div&gt;&lt;span class="fullpost"&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;I came to this conclusion after running my code for 30 minutes(total time). Yesterday, at the same time, I was working out a problem on arrays, the problem was "Given a sorted array of integers and a target value t, find if there exists a pair &lt;x, y=""&gt; (x, y) such that x + y = t and if yes, report these numbers." I solved this problem using 2 counters, first at start i = 0 and second at end, j = n-1, where n is the length of the array, if sum of a[i] and a[j] is greater than target value t, then I would decrement j, else increment i, so by following this greedy approach, I would eventually reach to the pair which sum to t (if at all), otherwise I would report that there is no such pair. I implemented this algorithm in C and run my code first for 10 numbers which worked fine and then I ran the code on 1 million numbers which also worked fine.&lt;/x,&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;So, how does it relates with primes? It does so in that if I can find primes up to a certain number n in sorted order (non decreasing) then if I now run my above code then I will be able to find if a given number (even) hopefully is a sum of two primes or not, this is a powerful result in finding out if any given even number is a sum of two primes or not, and has a very good practical application (&lt;a href="http://en.wikipedia.org/wiki/Goldbach%27s_conjecture"&gt;Goldbach's conjecture&lt;/a&gt;).&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Now, what I did is that I found out primes up to 112010 and ran my code over this sorted array of primes up to 112010 and I found out that this number is indeed a sum of two primes (111997 and 13)!&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Code available on request! Any queries, suggestions or comments are welcome!&lt;br /&gt;&lt;/div&gt;&lt;b&gt;&lt;br /&gt;Cheers!&lt;br /&gt;Rajendra&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1054067205364967531-4869406536206021585?l=rajendrauppal.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rajendrauppal.blogspot.com/feeds/4869406536206021585/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1054067205364967531&amp;postID=4869406536206021585' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/4869406536206021585'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/4869406536206021585'/><link rel='alternate' type='text/html' href='http://rajendrauppal.blogspot.com/2010/01/what-date-112010.html' title='What a date!? 1.1.2010'/><author><name>Rajendra Kumar Uppal</name><uri>http://www.blogger.com/profile/08197834521620905502</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_pBounEjPPcY/SLpMsEJb4_I/AAAAAAAAAAU/ewlBl-0W6R0/S220/in+Gtalk+(copy).JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1054067205364967531.post-3654211457557211227</id><published>2009-12-31T22:08:00.012+05:30</published><updated>2010-01-01T10:12:31.291+05:30</updated><title type='text'>Geany - Nice IDE for C/C++ development</title><content type='html'>Geany is a fast and lightweight IDE for C/C++ programming in Ubuntu environment. It is open source (free) and anyone who has access to internet connection and Ubuntu installed on their system, can install it using following command on terminal:&lt;br /&gt;&lt;span class="fullpost"&gt;&lt;br /&gt;&lt;code&gt;sudo apt-get install geany&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Alternatively, if you know and like to work with Synaptic package manager, then it is more intuitive to install Geany IDE using the SPM.&lt;br /&gt;&lt;br /&gt;After installation, you can run Geany from Applications --&amp;gt; Programming --&amp;gt; Geany, click on Geany to run it you would see something like following screens on your desktop/laptop: (Click on any image given in this post to view it full size)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_pBounEjPPcY/Sz11jlIlfOI/AAAAAAAAADU/6bwSFORcf60/s1600-h/Screenshot-1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_pBounEjPPcY/Sz11jlIlfOI/AAAAAAAAADU/6bwSFORcf60/s640/Screenshot-1.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;b&gt;Key features&lt;/b&gt; of this nice and fast IDE are following:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1.&lt;/b&gt; It is very fast in compilation, buiding executables, and running code;&lt;br /&gt;&lt;b&gt;2.&lt;/b&gt; You can run terminal inside this IDE to switch to your current working directory and run your executable, to debug your code through gdb;&lt;br /&gt;&lt;b&gt;3.&lt;/b&gt; It does not have irritating GUI, where many unnecessary things are bombarded;&lt;br /&gt;&lt;b&gt;4.&lt;/b&gt; You can insert file headers, like date, time, General public license, source headers(stdio.h etc...) very quickly;&lt;br /&gt;&lt;b&gt;5.&lt;/b&gt; It supports many prominent languages like, C, C++, Java, Fortran, Caml, D, FreeBasic, Haskell, Haxe, Pascal, Assembler source files.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_pBounEjPPcY/Sz11x0QGwcI/AAAAAAAAADc/IhjYzkpP_7Q/s1600-h/Screenshot-2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_pBounEjPPcY/Sz11x0QGwcI/AAAAAAAAADc/IhjYzkpP_7Q/s640/Screenshot-2.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;I would go through a bare basic example of C language to compile, build exe, running the exe.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Creating your first C source code&lt;/b&gt;, there are two ways you can do this: &lt;br /&gt;&lt;br /&gt;&lt;b&gt;(1.)&lt;/b&gt; create any folder anywhere in your system, name it whatever you wish, say “sample”, now make an empty file name it whatever you want to give to your C source file, for instance, say “sample.c”, give the extension .c this is necessary, double click on “sample.c”, it should open directly in Geany workspace, if you don't have any other IDE installed, but if you have, then it may not open in Geany by default, in this case, you would have to explicitly open it with Geany (right click on “sample.c” and open with Geany!). Now, you have your file opened in Geany workspace.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;(2.)&lt;/b&gt; just open Geany IDE from Applications --&amp;gt; Programming --&amp;gt; Geany and click down arrow near New in the menu bar of Geany, you would see options like, C source file, C++ source file etc... click on C source file and you are done.&lt;br /&gt;&lt;br /&gt;Now, from one of the above two steps, you have created your first C source file. You would like to see some action now, ok, if you are at any stage in C language (student, beginner, geek, professional, expert), you should be able to write any small piece of C code to see how Geany compiles, builds exe, and runs. I assume that you have or you will write any snippet within few minutes, now let's test it.&lt;br /&gt;&lt;b&gt;1. Compile:&lt;/b&gt; click F8 to compile(builds object file sample.o) and see how fast it compiles;&lt;br /&gt;&lt;b&gt;2. Build:&lt;/b&gt; click F9 to build executable(buids exe sample) and see how fast it does so.&lt;br /&gt;&lt;b&gt;3. Run:&lt;/b&gt; you can either run from terminal inside Geany or you can simply press F5 to run the executable you just build.&lt;br /&gt;That's it!&lt;br /&gt;Following are some screenshots giving you how nice it looks like programming with Geany and also demonstrates some of the points described above.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_pBounEjPPcY/Sz12ogPkXSI/AAAAAAAAADk/9GXwjc9hVO8/s1600-h/Screenshot-5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_pBounEjPPcY/Sz12ogPkXSI/AAAAAAAAADk/9GXwjc9hVO8/s640/Screenshot-5.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_pBounEjPPcY/Sz12wwQGA9I/AAAAAAAAADs/FK1_DlShC7o/s1600-h/7.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_pBounEjPPcY/Sz12wwQGA9I/AAAAAAAAADs/FK1_DlShC7o/s640/7.png" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;Any comments, suggestions and queries are most welcome.&lt;br /&gt;&lt;br /&gt;Cheers!&lt;br /&gt;Rajendra&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1054067205364967531-3654211457557211227?l=rajendrauppal.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rajendrauppal.blogspot.com/feeds/3654211457557211227/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1054067205364967531&amp;postID=3654211457557211227' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/3654211457557211227'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/3654211457557211227'/><link rel='alternate' type='text/html' href='http://rajendrauppal.blogspot.com/2009/12/geany-nice-ide-for-cc-development.html' title='Geany - Nice IDE for C/C++ development'/><author><name>Rajendra Kumar Uppal</name><uri>http://www.blogger.com/profile/08197834521620905502</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_pBounEjPPcY/SLpMsEJb4_I/AAAAAAAAAAU/ewlBl-0W6R0/S220/in+Gtalk+(copy).JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_pBounEjPPcY/Sz11jlIlfOI/AAAAAAAAADU/6bwSFORcf60/s72-c/Screenshot-1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1054067205364967531.post-5733523386570493996</id><published>2009-12-28T08:22:00.003+05:30</published><updated>2009-12-28T23:47:58.591+05:30</updated><title type='text'>Given n-th prime, find (n+1)-th prime!</title><content type='html'>&lt;b&gt;&lt;span style="font-family: Arial; font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;Problem: &lt;span style="font-weight: normal;"&gt;Given n-th prime, how do you find (n+1)-th prime? Write a function&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;span style="font-family: Arial; font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;&lt;span style="font-weight: normal;"&gt;&lt;code&gt;int GetNextPrime(int n);&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;span style="font-family: monospace; font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;Example:&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: monospace; font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;Input: 7 Output: 11 &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: monospace; font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;Input: 13 Output: 17&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: monospace; font-size: small;"&gt;&lt;span style="font-size: 13px;"&gt;Hint: Search for Bertrand's Postulate!&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1054067205364967531-5733523386570493996?l=rajendrauppal.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rajendrauppal.blogspot.com/feeds/5733523386570493996/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1054067205364967531&amp;postID=5733523386570493996' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/5733523386570493996'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/5733523386570493996'/><link rel='alternate' type='text/html' href='http://rajendrauppal.blogspot.com/2009/12/given-n-th-prime-find-n1-th-prime.html' title='Given n-th prime, find (n+1)-th prime!'/><author><name>Rajendra Kumar Uppal</name><uri>http://www.blogger.com/profile/08197834521620905502</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_pBounEjPPcY/SLpMsEJb4_I/AAAAAAAAAAU/ewlBl-0W6R0/S220/in+Gtalk+(copy).JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1054067205364967531.post-5872846796163437583</id><published>2009-11-25T08:22:00.007+05:30</published><updated>2011-11-01T09:17:39.858+05:30</updated><title type='text'>C source code to check IsFibonacci()</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;As promised, here is code to check for any given number belongs to Fibonacci series or not?&lt;br /&gt;&lt;span class="fullpost"&gt;&lt;br /&gt;/*&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Theorem:&lt;/span&gt;&lt;br /&gt;A positive integer n is Fibonacci if, and only if, (5*n*n+4) OR (5*n*n+4) is a perfect square.&lt;br /&gt;*/&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="fullpost"&gt;bool IsFibonacci(int n)&lt;br /&gt;{&lt;br /&gt;    // Calculate criteria expressions&lt;br /&gt;    int criteria[2];&lt;br /&gt;    criteria[0] = 5 * n * n + 4;&lt;br /&gt;    criteria[1] = 5 * n * n - 4;&lt;br /&gt;&lt;br /&gt;    // Determine whether one of them is a perfect square&lt;br /&gt;    int sqr[2];&lt;br /&gt;    sqr[0] = sqrt(criteria[0]);&lt;br /&gt;    sqr[1] = sqrt(criteria[1]);&lt;br /&gt;&lt;br /&gt;    // Return result&lt;br /&gt;    return ((pow(sqr[0], 2) == criteria[0]) || (pow(sqr[1], 2) == criteria[1]));&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span class="fullpost"&gt;Comments and suggestions are always welcome!&lt;br /&gt;&lt;b&gt;&lt;br /&gt;Cheers!&lt;br /&gt;Rajendra&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1054067205364967531-5872846796163437583?l=rajendrauppal.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rajendrauppal.blogspot.com/feeds/5872846796163437583/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1054067205364967531&amp;postID=5872846796163437583' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/5872846796163437583'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/5872846796163437583'/><link rel='alternate' type='text/html' href='http://rajendrauppal.blogspot.com/2009/11/c-source-code-to-check-isfibonacci.html' title='C source code to check IsFibonacci()'/><author><name>Rajendra Kumar Uppal</name><uri>http://www.blogger.com/profile/08197834521620905502</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_pBounEjPPcY/SLpMsEJb4_I/AAAAAAAAAAU/ewlBl-0W6R0/S220/in+Gtalk+(copy).JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1054067205364967531.post-6556782160504077796</id><published>2009-11-20T01:53:00.009+05:30</published><updated>2010-01-09T20:50:31.554+05:30</updated><title type='text'>How to know that a given number is Fibonacci or not?</title><content type='html'>Hi,&lt;br /&gt;&lt;br /&gt;I am back after a long time! I am assuming the reader is well acquainted with Fibonacci numbers. Still here goes the definition:&lt;br /&gt;&lt;br /&gt;The sequence of numbers beginning&lt;br /&gt;0, 1, 1, 2, 3, 5, 8, 13...&lt;br /&gt;where each successive number in the sequence is the sum of the two preceding numbers. More precisely the sequence can be defined through the recurrence relation:&lt;br /&gt;&lt;br /&gt;F(n) = 0, if n = 0&lt;br /&gt;= 1, if n = 1&lt;br /&gt;= F(n-1)+F(n-2), if n &gt; 1&lt;br /&gt;&lt;span class="fullpost"&gt;&lt;br /&gt;Following C source code returns the n-th Fibonacci number:&lt;br /&gt;&lt;pre&gt;int Fibonacci(int n)&lt;br /&gt;{&lt;br /&gt;if (n == 0 || n == 1)&lt;br /&gt;return n;&lt;br /&gt;else&lt;br /&gt;return Fibonacci(n - 1) + Fibonacci(n - 2);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now, here comes my primary objective of writing this post:&lt;br /&gt;&lt;br /&gt;How to know whether a given number belongs to Fibonacci series or not?&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;OR&lt;/span&gt;&lt;br /&gt;How to know that a given number is Fibonacci or not?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Algorithm 1. (Naive approach)&lt;/span&gt;&lt;br /&gt;Input: n&lt;br /&gt;Output: true or false&lt;br /&gt;&lt;br /&gt;// Calculate Fibonacci numbers till we reach equal to or exceed n&lt;br /&gt;&lt;br /&gt;// Return true if we found any of the calculated numbers equal to n&lt;br /&gt;// and return false otherwise&lt;br /&gt;&lt;br /&gt;This algorithm is inefficient.&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now, here we are at the point where crux of the whole story is.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Theorem:&lt;/span&gt; A number n is Fibonacci if, and only if, (5*n*n + 4) OR (5*n*n - 4) is a perfect square.&lt;span style="font-weight: bold;"&gt;[Ira Gessel 1972]&lt;/span&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Check out my next post for the proof of this theorem or google it!&lt;br /&gt;&lt;br /&gt;Checking for perfect square is easy as follows:&lt;br /&gt;1. take the square root of the number;&lt;br /&gt;2a. Just check if fractional part is zero (suggested by Equinox) OR&lt;br /&gt;&lt;br /&gt;2b. discard its fractional part;&lt;br /&gt;3. take square of the integral part;&lt;br /&gt;4. if this square is equal to given number then number is a perfect square or it is not.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;NEXT POST:&lt;/span&gt; C code for above theorem and proof of the theorem.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Cheers!&lt;br /&gt;Rajendra&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1054067205364967531-6556782160504077796?l=rajendrauppal.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rajendrauppal.blogspot.com/feeds/6556782160504077796/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1054067205364967531&amp;postID=6556782160504077796' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/6556782160504077796'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/6556782160504077796'/><link rel='alternate' type='text/html' href='http://rajendrauppal.blogspot.com/2009/11/came-back.html' title='How to know that a given number is Fibonacci or not?'/><author><name>Rajendra Kumar Uppal</name><uri>http://www.blogger.com/profile/08197834521620905502</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_pBounEjPPcY/SLpMsEJb4_I/AAAAAAAAAAU/ewlBl-0W6R0/S220/in+Gtalk+(copy).JPG'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1054067205364967531.post-512215001412390427</id><published>2008-10-12T15:45:00.008+05:30</published><updated>2009-12-08T09:55:40.165+05:30</updated><title type='text'>Implementation of my division algorithm in C++</title><content type='html'>&lt;div style="text-align: justify;"&gt;Hello guys, I have written a new approach (in C++) towards dividing two large numbers, input is dividend and divisor, and output shall be quotient and remainder. The algorithm and source code in C++ is presented here "as-is", anyone can use it, without any warranty to the damage(s) that may happen. The source code in text format is well documented and is self-explanatory.&lt;br /&gt;&lt;/div&gt;&lt;span class="fullpost"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;ALGORITHM:&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;INPUT&lt;/span&gt;    : Dividend, Divisor&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;OUTPUT&lt;/span&gt;: Quotient, Remainder&lt;br /&gt;&lt;pre&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;static int&lt;/span&gt; cnt;&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;if&lt;/span&gt; (dividend = divisor)&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;   return&lt;/span&gt; quotient = 0, remainder = 0&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;else if&lt;/span&gt; (dividend &lt; divisor)   &lt;br /&gt;return quotient = 0, remainder = dividend &lt;span style="color: rgb(102, 0, 0);"&gt;&lt;br /&gt;else&lt;/span&gt;  &lt;br /&gt;{&lt;br /&gt;&lt;span style="color: rgb(0, 102, 0);"&gt;   static int&lt;/span&gt; residue = dividend;  &lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;   while&lt;/span&gt;(residue &gt;= divisor)&lt;br /&gt;{&lt;br /&gt;residue = residue - divisor;&lt;br /&gt;cnt++;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;span style="color: rgb(102, 0, 0);"&gt;return&lt;/span&gt; quotient = cnt; remainder = residue;&lt;br /&gt;&lt;/pre&gt;The source code in C++ can be downloaded from &lt;a href="http://sites.google.com/site/thecplusplus/Home/division.cpp?attredirects=0"&gt;&lt;span style="font-weight: bold;"&gt;HERE&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;iostream&gt;&lt;/iostream&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1054067205364967531-512215001412390427?l=rajendrauppal.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rajendrauppal.blogspot.com/feeds/512215001412390427/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1054067205364967531&amp;postID=512215001412390427' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/512215001412390427'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/512215001412390427'/><link rel='alternate' type='text/html' href='http://rajendrauppal.blogspot.com/2008/10/implementation-of-my-division-algorithm.html' title='Implementation of my division algorithm in C++'/><author><name>Rajendra Kumar Uppal</name><uri>http://www.blogger.com/profile/08197834521620905502</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_pBounEjPPcY/SLpMsEJb4_I/AAAAAAAAAAU/ewlBl-0W6R0/S220/in+Gtalk+(copy).JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1054067205364967531.post-598273397372782187</id><published>2008-10-06T02:02:00.005+05:30</published><updated>2009-12-08T09:27:41.964+05:30</updated><title type='text'>My 5 Golden Rules about Interviews!</title><content type='html'>&lt;div style="text-align: justify;"&gt;Hello friends! Let me talk something about my previous post first! My previous post addressed the interview issues regarding the language questions. However, we all know that there are less language questions than that of ((Data Structures, Problem Solving, Algorithms, OS, Networks, etc.))(From now onwards, called 'BUNCH') These are the most important among all of the topics and is the topic of my discussion in this post too.&lt;br /&gt;&lt;span class="fullpost"&gt;&lt;br /&gt;&lt;b&gt;RULE 1. "Know Your Enemy( The host)":&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;You need to understand that the techie on the other side of the table who is going to interview you, is a technical person in the  company, has sound knowledge of the Bunch(even if you doubt the 'soundness', there is no harm in assuming it!!), He knows answers to all the questions which he is going to ask you very well(obviously, but answering the problems you know answers already isn't a big deal, so this shouldn't give you the impression of his knowledge on the subject!).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;RULE 2. "Host isn't The Champ":&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;I hope you have understood the rule 1, now you know that what your host is, so make it very very clear in your mind that "Nobody learned from birth, it is this world which have given you all the knowledge or whatsoever" and the host is no exception at all, so rule 2 is that host isn't the champ, he was like you once, you will be like him some day, please don't misunderstand me, I don't mean that you underestimate him, I just want to make sure that you feel confident, feel standing on your feet, have poise, and don't shake."&lt;br /&gt;&lt;br /&gt;&lt;b&gt;RULE 3. "If you know the answer beforehand, pretend as if you solved it right now"&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;That should be fairly simple idea for you guys, you have done it many times before with your friends, family etc., you remember/noticed it or not, but ya true, sometime we pretend in giving some answer so well that the other person can't catch. This happens often in puzzles, we solve so many puzzles that we remember the data in the question as well as the answer, or atleast the way to solve it, and we pretend too! Fair enough, go ahead, keep doing it, the only thing that changes here in the interview is that you have to do the same thing in a very formal and sophisticated manner.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;RULE 4. "Understand why the problem has been given to you"&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;That sounds stupid, isn't it? Really not, as will be clear soon. The problem has been given to me because&lt;br /&gt;No.  1.  I am being interviewed.&lt;br /&gt;No.  2.  Host want me to solve the problem, or atleast I try it hard.&lt;br /&gt;No. 3. Host want to see how easy/tough/fast/late I give up, means I fought.&lt;br /&gt;OK, fine, bottom line is that the host has given you the problem to check the following:&lt;br /&gt;1. How fast you solve, even if you solve it!&lt;br /&gt;2. How efficient is your solution(in terms of complexity).&lt;br /&gt;3. If you haven't solved it, did you quit early?&lt;br /&gt;4. If you haven't solved it, how long you fought with the problem to find the solution?&lt;br /&gt;&lt;br /&gt;&lt;b&gt;RULE 5. "NEVER EVER GIVE UP"&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;My interview experience advocates this principle of never-ever-giving-up.&lt;br /&gt;&lt;/div&gt;I found this principle applicable everywhere, let me make it more clear to you guys, many times, such situations happened before me (including interviews, friends etc.) that this golden rule helped me. Never giving up gives you a sense of fighter, that reflects on your face, you don't really have to pretend it though, but remember one thing actions and feelings go together, by regulating the actions, we can indirectly regulate the feelings which are not in our direct control. So guys, be wise, and never give up.&lt;br /&gt;&lt;br /&gt;&lt;b style="color: rgb(102, 0, 0);"&gt;BOTTOM LINE:&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;"No matter how hard the given problem is, no matter you have heard about it before or not, no matter nothing, fight with a problem to solve it like a tiger goes for its hunt, and never ever give up. The host want to see how hard you tried!"&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Cheers!&lt;/b&gt;&lt;br /&gt;&lt;b&gt;Rajendra&lt;/b&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1054067205364967531-598273397372782187?l=rajendrauppal.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rajendrauppal.blogspot.com/feeds/598273397372782187/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1054067205364967531&amp;postID=598273397372782187' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/598273397372782187'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/598273397372782187'/><link rel='alternate' type='text/html' href='http://rajendrauppal.blogspot.com/2008/10/hello-friends-let-me-talk-something.html' title='My 5 Golden Rules about Interviews!'/><author><name>Rajendra Kumar Uppal</name><uri>http://www.blogger.com/profile/08197834521620905502</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_pBounEjPPcY/SLpMsEJb4_I/AAAAAAAAAAU/ewlBl-0W6R0/S220/in+Gtalk+(copy).JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1054067205364967531.post-1935475165317137030</id><published>2008-10-02T12:38:00.004+05:30</published><updated>2009-12-08T09:32:47.442+05:30</updated><title type='text'>A bit from my Interview Mantra!!</title><content type='html'>&lt;div style="text-align: justify;"&gt;Surprisingly, a sudden turn from my pot! I am going to talk about  my interview  experience and want to share a bit!&lt;span class="fullpost"&gt;&lt;br /&gt;In my little yet good experience, interviews want to know that you know the language (a little bit) and that you understand data structures and/or algorithms (ie programming techniques not necessarily language specific) and more importantly can see how you combine both. They also like to see that you can think.&lt;br /&gt;&lt;br /&gt;While I doubt there are "standard" questions, I would suggest studying some data structures and thinking about what you can do with them (I think lists, queues/stacks and binary trees would be the most likely).&lt;br /&gt;&lt;br /&gt;To show you can think, they will usually ask you to manipulate/work with the structure to do something slightly out of the ordinary (that is, they will assume you can create/traverse the structure but will have you solve a problem with it). &lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;For Example:&lt;/span&gt; One that I have experienced before (more than once) relates to finding the midpoint of a linked list.&lt;br /&gt;&lt;br /&gt;It is also good to understand how different data structures vary (eg difference between doubly &amp;amp; singly linked list, queue and stack) as well as differences in simple algorithms (eg post-order/pre-order/inorder traversal of trees, different search and sort methods).&lt;br /&gt;&lt;br /&gt;A lot depeneds on the type of position. If you are going for a graduate/entry level position, they often want to gauge what you know. This means they will talk to you before asking questions and ask you your strengths. Try to sell the ideas listed above that you understand, to prompt for a question in that area (to confirm your story). For example:&lt;br /&gt;&lt;br /&gt;Q: What areas did you study at School?&lt;br /&gt;A: I completed courses in Software Engineering, Artificial Intelligence and Data Structures and Algorithms. During the Data Structures and Algorithms course my major project required me to design a simple program to store University Enrolments. Focusing on optimizing search times rather than Add/Delete times, I decided to organize my data in a Binary tree....etc&lt;br /&gt;&lt;br /&gt;In this way, you claim "I know about BT's" and you should get a question on one. As with School, ultimately the prospective employer wants to know what you know not what you don't know.&lt;br /&gt;&lt;br /&gt;Of course, different companies, different countries possibly different story, but in my experience: Always sell your knowledge, and try (not always possible) to steer interviews toward areas you know. Most important though, be confident but not cocky and don't just make things up if you don't know (even if the interviewer is only a human resource manager).&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Cheers!&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Rajendra&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1054067205364967531-1935475165317137030?l=rajendrauppal.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rajendrauppal.blogspot.com/feeds/1935475165317137030/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1054067205364967531&amp;postID=1935475165317137030' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/1935475165317137030'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/1935475165317137030'/><link rel='alternate' type='text/html' href='http://rajendrauppal.blogspot.com/2008/10/bit-from-my-interview-mantra.html' title='A bit from my Interview Mantra!!'/><author><name>Rajendra Kumar Uppal</name><uri>http://www.blogger.com/profile/08197834521620905502</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_pBounEjPPcY/SLpMsEJb4_I/AAAAAAAAAAU/ewlBl-0W6R0/S220/in+Gtalk+(copy).JPG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1054067205364967531.post-4025982670451178374</id><published>2008-09-11T06:58:00.017+05:30</published><updated>2009-12-08T09:49:34.345+05:30</updated><title type='text'>How I got introduced to Qt and some basics?</title><content type='html'>Hello friends,&lt;br /&gt;Today, I am going to talk about something very off-the-line and new, it's &lt;span style="font-weight: bold;"&gt;Qt&lt;/span&gt;. What is this? we will come to this later.&lt;br /&gt;&lt;br /&gt;How I came to this? Actually, ... &lt;span class="fullpost"&gt;there is indirect link to, me reaching at Qt. I had XP on my laptop, and just 1 month before, I removed XP completely, and installed UBUNTU 8.04 in my suddenly awaken sense of open source sharing, pirated software crime etc. !!!&lt;br /&gt;&lt;br /&gt;Things went very well, as I was doing my routine work, But I realized that, MS VC++, VB, is so strong for my application development, and I didn't know whether I can develop or learn my GUI, event based applications in Eclipse? (I still don't know!).&lt;br /&gt;So, I was chatting once to my &lt;em&gt;colleague &lt;/em&gt;Deepak on tea, we were chatting about why I wanted to switch to XP again? He suggested, use Qt yar, it is for C++ GUI development.&lt;br /&gt;So, this way, I reached to Qt.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;What is Qt anyway?&lt;/span&gt;&lt;br /&gt;Developed by: Norwegian Company Trolltech&lt;br /&gt;Qt is a multiplatform C++ GUI toolkit. It provides application developers with all the functionality needed to build applications with state-of-the-art graphical user interfaces. Qt is fully object-oriented, easily extensible, and allows true component programming.&lt;br /&gt;Most suitable link for resources, about Qt FAQ's, help, forums, technical FAQ's, is :&lt;br /&gt;&lt;a href="http://www.trolltech.com/"&gt;TROLLTECH&lt;/a&gt;        -      http://www.trolltech.com/&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Installation:&lt;/span&gt;&lt;br /&gt;Option 1.&lt;br /&gt;Use Synaptic;&lt;br /&gt;Option 2.&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt2" dir="ltr" style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 640px; height: 50px; text-align: left;"&gt;apt-get install libqt4-core libqt4-dev libqt4-gui qt4-dev-tools qt4-designer&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;After, downloading packages and installation is done, go to&lt;br /&gt;&lt;span style="font-style: italic;"&gt; Applications&lt;/span&gt; --&gt; &lt;span style="font-style: italic;"&gt;Programming&lt;/span&gt; --&gt; you will see...&lt;br /&gt;Qt4 Assistant&lt;br /&gt;Qt4 Designer&lt;br /&gt;Qt4 Linguist&lt;br /&gt;Click on designer to view your beautiful, GUI to create C++ GUI applications.&lt;br /&gt;You will see:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_pBounEjPPcY/SMiCqGLAJmI/AAAAAAAAACY/DKc4ZPxesqI/s1600-h/Qt4+Designer.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_pBounEjPPcY/SMiCqGLAJmI/AAAAAAAAACY/DKc4ZPxesqI/s400/Qt4+Designer.png" alt="" id="BLOGGER_PHOTO_ID_5244585425795819106" border="0" /&gt;&lt;/a&gt;P.S.: credits for information available here is to :             &lt;a href="http://www.trolltech.com/"&gt;TROLLTECH&lt;/a&gt;&lt;br /&gt;Following is the fundamental sequence of implementation events that happens in any GUI, or event-based application:&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 1.&lt;/span&gt; Design your GUI according to your application's requirements;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 2.&lt;/span&gt; Add properties and variable names to the controls in your GUI;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Step 3.&lt;/span&gt; Add code to controls.&lt;br /&gt;More to come ...&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Cheers!&lt;br /&gt;Rajendra&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1054067205364967531-4025982670451178374?l=rajendrauppal.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://rajendrauppal.blogspot.com/feeds/4025982670451178374/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1054067205364967531&amp;postID=4025982670451178374' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/4025982670451178374'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1054067205364967531/posts/default/4025982670451178374'/><link rel='alternate' type='text/html' href='http://rajendrauppal.blogspot.com/2008/09/how-i-got-introduced-to-qt-and-some.html' title='How I got introduced to Qt and some basics?'/><author><name>Rajendra Kumar Uppal</name><uri>http://www.blogger.com/profile/08197834521620905502</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='27' src='http://4.bp.blogspot.com/_pBounEjPPcY/SLpMsEJb4_I/AAAAAAAAAAU/ewlBl-0W6R0/S220/in+Gtalk+(copy).JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_pBounEjPPcY/SMiCqGLAJmI/AAAAAAAAACY/DKc4ZPxesqI/s72-c/Qt4+Designer.png' height='72' width='72'/><thr:total>4</thr:total></entry></feed>
