tag:blogger.com,1999:blog-61948392017-08-09T04:45:51.183+05:30Balbir's BlogI describe all the programming and non-programming stuff I doBalbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.comBlogger436125tag:blogger.com,1999:blog-6194839.post-3503873854271945602017-07-09T06:34:00.000+05:302017-07-09T06:34:19.117+05:30Dynamic programming for the binomial coefficient<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on">More fun things, this time with some visualisation of what happens when memoisation is used and what happens when we don't. I don't these these algorithms are the most efficient algorithms<br /><br /><br /></div><style type="text/css"><!-- pre { white-space: pre-wrap; font-family: monospace; color: #000000; background-color: #ffffff; } body { font-family: monospace; color: #000000; background-color: #ffffff; } * { font-size: 1em; } .Identifier { color: #008b8b; } .Statement { color: #a52a2a; font-weight: bold; } .Comment { color: #0000ff; } .Constant { color: #ff00ff; } </style></div> <pre id="vimCodeElement"><span class="Comment">#</span><br /><span class="Comment"># dynamic programming for binomial co-efficient</span><br /><span class="Comment">#</span><br /><span class="Statement">def</span> <span class="Identifier">dynamic_bc</span>(n, k, indent=<span class="Constant">0</span>):<br /> <span class="Comment">#</span><br /> <span class="Comment"># return (n k) using dynamic programming</span><br /> <span class="Comment"># tail cases are k == 0 or k == 1</span><br /> <span class="Comment"># (n 0) = 1 and (n 1) = n</span><br /> <span class="Statement">for</span> i <span class="Statement">in</span> <span class="Identifier">range</span>(<span class="Constant">0</span>, indent):<br /> <span class="Identifier">print</span> <span class="Constant">"</span><span class="Constant"> </span><span class="Constant">"</span>,<br /> <span class="Identifier">print</span> <span class="Constant">"</span><span class="Constant">%d:%d</span><span class="Constant">"</span> %(n, k)<br /> <span class="Statement">if</span> (k == <span class="Constant">0</span>):<br /> arr[n][k] = <span class="Constant">1</span><br /> <span class="Statement">return</span> <span class="Constant">1</span><br /> <span class="Statement">if</span> (k == <span class="Constant">1</span>):<br /> arr[n][k] = n<br /> <span class="Statement">return</span> n<br /> <span class="Statement">if</span> (n == k):<br /> arr[n][k] = <span class="Constant">1</span><br /> <span class="Statement">return</span> <span class="Constant">1</span><br /> <span class="Comment"># (n k) = (n!)/(n-k)!k!, lets split it further</span><br /> <span class="Comment"># n!/(n-k)!k! = n(n-1)!/(n-k)!k(k-1)!</span><br /> <span class="Comment"># or (n k) = (n-1 k) + (n -1 k-1)</span><br /> <span class="Statement">if</span> (arr[n-<span class="Constant">1</span>][k-<span class="Constant">1</span>] == <span class="Constant">0</span>):<br /> arr[n-<span class="Constant">1</span>][k-<span class="Constant">1</span>] = dynamic_bc(n-<span class="Constant">1</span>,k-<span class="Constant">1</span>,indent+<span class="Constant">1</span>)<br /> <span class="Statement">if</span> (arr[n-<span class="Constant">1</span>][k] == <span class="Constant">0</span>):<br /> arr[n-<span class="Constant">1</span>][k] = dynamic_bc(n-<span class="Constant">1</span>, k,indent+<span class="Constant">1</span>)<br /> <span class="Statement">return</span> arr[n-<span class="Constant">1</span>][k] + arr[n-<span class="Constant">1</span>][k-<span class="Constant">1</span>]<br /><br /><span class="Statement">def</span> <span class="Identifier">bc</span>(n, k, indent=<span class="Constant">0</span>):<br /> <span class="Comment">#</span><br /> <span class="Comment"># tail cases are k == 0 or k == 1</span><br /> <span class="Comment"># (n 0) = 1 and (n 1) = n</span><br /> <span class="Statement">for</span> i <span class="Statement">in</span> <span class="Identifier">range</span>(<span class="Constant">0</span>, indent):<br /> <span class="Identifier">print</span> <span class="Constant">"</span><span class="Constant"> </span><span class="Constant">"</span>,<br /> <span class="Identifier">print</span> <span class="Constant">"</span><span class="Constant">%d:%d</span><span class="Constant">"</span> %(n, k)<br /> <span class="Statement">if</span> (k == <span class="Constant">0</span>):<br /> <span class="Statement">return</span> <span class="Constant">1</span><br /> <span class="Statement">if</span> (k == <span class="Constant">1</span>):<br /> <span class="Statement">return</span> n<br /> <span class="Statement">if</span> (n == k):<br /> <span class="Statement">return</span> <span class="Constant">1</span><br /> <span class="Comment"># (n k) = (n!)/(n-k)!k!, lets split it further</span><br /> <span class="Comment"># n!/(n-k)!k! = n(n-1)!/(n-k)!k(k-1)!</span><br /> <span class="Comment"># or (n k) = (n-1 k) + (n -1 k-1)</span><br /> <span class="Statement">return</span> bc(n-<span class="Constant">1</span>,k,indent+<span class="Constant">1</span>) + bc(n-<span class="Constant">1</span>,k-<span class="Constant">1</span>,indent+<span class="Constant">1</span>)<br /><br />number = <span class="Constant">6</span><br />select = <span class="Constant">3</span><br />arr = [[<span class="Constant">0</span> <span class="Statement">for</span> x <span class="Statement">in</span> <span class="Identifier">range</span>(<span class="Constant">0</span>, number)] <span class="Statement">for</span> x <span class="Statement">in</span> <span class="Identifier">range</span>(<span class="Constant">0</span>, number)]<br /><br /><span class="Identifier">print</span> bc(number, select)<br /><span class="Identifier">print</span> dynamic_bc(number, select)</pre> The output for the first call with full recursion <pre><br /><br />6:3<br /> 5:3<br /> 4:3<br /> 3:3<br /> 3:2<br /> 2:2<br /> 2:1<br /> 4:2<br /> 3:2<br /> 2:2<br /> 2:1<br /> 3:1<br /> 5:2<br /> 4:2<br /> 3:2<br /> 2:2<br /> 2:1<br /> 3:1<br /> 4:1<br />20<br /><br /></pre> The output for For the first call with full recursion <pre><br /><br />6:3<br /> 5:2<br /> 4:1<br /> 4:2<br /> 3:1<br /> 3:2<br /> 2:1<br /> 2:2<br /> 5:3<br /> 4:3<br /> 3:3<br />20<br /></pre> Python supports memoization via functools (wraps, lru_cache, etc). I am using the wrapper (decorator pattern). Using the following pattern makes the programming so transparent <pre id='vimCodeElement'><br /><span class="Comment">#</span><br /><span class="Comment"># dynamic programming for binomial co-efficient</span><br /><span class="Comment">#</span><br /><span class="PreProc">from</span> functools <span class="PreProc">import</span> wraps<br /><br /><span class="Statement">def</span> <span class="Identifier">dynamic_bc2</span>(func):<br /> cache = {}<br /> <span class="Statement">def</span> <span class="Identifier">wrap</span>(*args):<br /> <span class="Statement">if</span> args <span class="Statement">not</span> <span class="Statement">in</span> cache:<br /> cache[args] = func(*args)<br /> <span class="Statement">return</span> cache[args]<br /> <span class="Statement">return</span> wrap<br /><br /><span class="PreProc">@</span><span class="Identifier">dynamic_bc2</span><br /><span class="Statement">def</span> <span class="Identifier">bc2</span>(n, k, indent=<span class="Constant">0</span>):<br /> <span class="Comment">#</span><br /> <span class="Comment"># return (n k) using dynamic programming</span><br /> <span class="Comment"># tail cases are k == 0 or k == 1</span><br /> <span class="Comment"># (n 0) = 1 and (n 1) = n</span><br /> <span class="Statement">for</span> i <span class="Statement">in</span> <span class="Identifier">range</span>(<span class="Constant">0</span>, indent):<br /> <span class="Identifier">print</span> <span class="Constant">&quot;</span><span class="Constant"> </span><span class="Constant">&quot;</span>,<br /> <span class="Identifier">print</span> <span class="Constant">&quot;</span><span class="Constant">%d:%d</span><span class="Constant">&quot;</span> %(n, k)<br /> <span class="Statement">if</span> (k == <span class="Constant">0</span>):<br /> <span class="Statement">return</span> <span class="Constant">1</span><br /> <span class="Statement">if</span> (k == <span class="Constant">1</span>):<br /> <span class="Statement">return</span> n<br /> <span class="Statement">if</span> (n == k):<br /> <span class="Statement">return</span> <span class="Constant">1</span><br /> <span class="Comment"># (n k) = (n!)/(n-k)!k!, lets split it further</span><br /> <span class="Comment"># n!/(n-k)!k! = n(n-1)!/(n-k)!k(k-1)!</span><br /> <span class="Comment"># or (n k) = (n-1 k) + (n -1 k-1)</span><br /> <span class="Statement">return</span> bc2(n-<span class="Constant">1</span>,k-<span class="Constant">1</span>,indent+<span class="Constant">1</span>) + bc2(n-<span class="Constant">1</span>,k,indent+<span class="Constant">1</span>)<br /><br />number = <span class="Constant">6</span><br />select = <span class="Constant">3</span><br /><br /><span class="Identifier">print</span> bc2(number, select)<br /></pre> Comparing the output will show the affect of functools. The output with functools is: <pre><br />6:3<br /> 5:2<br /> 4:1<br /> 4:2<br /> 3:1<br /> 3:2<br /> 2:1<br /> 2:2<br /> 5:3<br /> 4:3<br /> 3:3<br />20<br /><br /></pre> Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com0tag:blogger.com,1999:blog-6194839.post-17115293219079483382017-07-06T13:36:00.001+05:302017-07-06T13:36:27.862+05:30Iterative combinations algorithm<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on">The algorithm is quite straight forward, see the code in python below<br /><br /><br /></div><style type="text/css"><!-- pre { white-space: pre-wrap; font-family: monospace; color: #000000; background-color: #ffffff; } body { font-family: monospace; color: #000000; background-color: #ffffff; } * { font-size: 1em; } .Identifier { color: #008b8b; } .Statement { color: #a52a2a; font-weight: bold; } .Comment { color: #0000ff; } .Constant { color: #ff00ff; } </style></div><pre id="vimCodeElement"><span class="Comment">#</span><br /><span class="Comment"># Do iterative combinations generation</span><br /><span class="Comment"># From Knuth's observation, we know for (6 3) that</span><br /><span class="Comment"># [0, 1, 2]</span><br /><span class="Comment"># [0, 1, 3]</span><br /><span class="Comment"># ..</span><br /><span class="Comment"># [3, 4, 5]</span><br /><span class="Comment"># Basically we can see a set of for loops, if we call the columns c1,c2 and c3 then</span><br /><span class="Comment">#</span><br /><span class="Comment"># for c3 = 2 to n-1</span><br /><span class="Comment"># for c2 = 1 to c3-1</span><br /><span class="Comment"># for c1 = 0 to c2-1</span><br /><span class="Comment">#</span><br /><span class="Comment"># The loop gives us what we need</span><br /><span class="Comment"># My implementation is based on an index (i) and max (n)</span><br /><span class="Comment"># which are used to determine the next value to generate</span><br /><span class="Comment">#</span><br /><span class="Statement">def</span> <span class="Identifier">iterative_combination</span>(n, k):<br /> a = [i <span class="Statement">for</span> i <span class="Statement">in</span> <span class="Identifier">range</span>(<span class="Constant">0</span>, n)]<br /> index = k - <span class="Constant">1</span><br /> done = <span class="Identifier">False</span><br /> <span class="Statement">while</span> (done == <span class="Identifier">False</span>):<br /> <span class="Identifier">print</span> a[<span class="Constant">0</span>:k]<br /> <span class="Statement">while</span> (a[index] == n - (k - index)): # boundary for that index<br /> index = index - <span class="Constant">1</span><br /> <span class="Statement">if</span> (index &lt; <span class="Constant">0</span>):<br /> done = <span class="Identifier">True</span><br /> <span class="Statement">break</span><br /> a[index] = a[index] + <span class="Constant">1</span><br /> <span class="Statement">while</span> (index &lt; k - <span class="Constant">1</span>):<br /> index = index + <span class="Constant">1</span><br /> <span class="Statement">if</span> (a[index] == (n - (k - index))): # initialize the next neighbour<br /> a[index] = a[index - <span class="Constant">1</span>] + <span class="Constant">1</span><br /><br /></pre></div>Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com0tag:blogger.com,1999:blog-6194839.post-2100731972758833692017-07-06T12:29:00.002+05:302017-07-06T12:29:10.842+05:30Random CS picture<div dir="ltr" style="text-align: left;" trbidi="on">Here is a random picture from a computer science topic<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://4.bp.blogspot.com/-PJO3IzNU5yM/WV3fR6ZNU7I/AAAAAAAAgY0/sHuBBp7nbnUr5rq84wfbKEhCnQmYuta6gCLcBGAs/s1600/set_cover.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="181" data-original-width="172" src="https://4.bp.blogspot.com/-PJO3IzNU5yM/WV3fR6ZNU7I/AAAAAAAAgY0/sHuBBp7nbnUr5rq84wfbKEhCnQmYuta6gCLcBGAs/s1600/set_cover.png" /></a></div><br /><br />The picture is a counter example of why greedy selection does not work optimally for the set cover problem. If the picture seems not so well done, it's because my asymptote skills are lacking :)<br /><br />You can probably guess what I'm reading by connecting set cover with combinatorial generation of combinations.</div>Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com0tag:blogger.com,1999:blog-6194839.post-22351066773668994132017-07-05T16:29:00.001+05:302017-07-05T16:34:13.965+05:30Combinations revisited<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on">I've been trying to relearn some of the combinatorics I used to know, I redid a nice recursive algorithm (from early university days), with python it looks so beautiful and nice. A simple implementation is below, so nice and simple.<br /><br /><br /></div><div dir="ltr" style="text-align: left;" trbidi="on"><style>pre { white-space: pre-wrap; font-family: monospace; color: #000000; background-color: #ffffff; } body { font-family: monospace; color: #000000; background-color: #ffffff; } * { font-size: 1em; } .Identifier { color: #008b8b; } .Statement { color: #a52a2a; font-weight: bold; } .Comment { color: #0000ff; } .Constant { color: #ff00ff; } </style> <br /><pre id="vimCodeElement"><span class="Comment">#</span><br /><span class="Comment"># I'm inspired by two algorithms I saw, both are recursive.</span><br /><span class="Comment">#</span><br /><span class="Comment"># Example:</span><br /><span class="Comment"># ((1, 2, 3, 4), 2) - means select 2 out of 3</span><br /><span class="Comment"># should produce (1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)</span><br /><span class="Comment">#</span><br /><span class="Comment"># The idea from a recursive perspective is this</span><br /><span class="Comment"># we pick an index - say 1, then we pick the next (n-1) elements</span><br /><span class="Comment"># to go with it</span><br /><span class="Comment">#</span><br /><br /><span class="Statement">def</span> <span class="Identifier">rec_comb</span>(a, i, j, k, n):<br /> <span class="Comment">#</span><br /> <span class="Comment"># array a built upto index i</span><br /> <span class="Comment"># selected k at a time of max</span><br /> <span class="Comment"># length n</span><br /> <span class="Comment">#</span><br /> <span class="Statement">if</span> (i == k):<br /> <span class="Identifier">print</span> a[<span class="Constant">0</span>:k]<br /> <span class="Statement">return</span><br /> <span class="Statement">for</span> l <span class="Statement">in</span> <span class="Identifier">range</span>(j, n):<br /> a[i] = l<br /> rec_comb(a, i+<span class="Constant">1</span>, l+<span class="Constant">1</span>, k, n)<br /> <span class="Statement">return</span><br /><br /><span class="Statement">def</span> <span class="Identifier">combination</span>(n, k):<br /> <span class="Comment">#</span><br /> <span class="Comment"># n (numbers from 1..n), chosen k at a time</span><br /> <span class="Comment">#</span><br /> a = [<span class="Constant">0</span> <span class="Statement">for</span> i <span class="Statement">in</span> <span class="Identifier">range</span>(<span class="Constant">0</span>, n)]<br /> rec_comb(a, <span class="Constant">0</span>, <span class="Constant">0</span>, k, n)</pre>The sample output for ${6 \choose 3}$ is: <br /><pre id="vimCodeElement"></pre><pre id="vimCodeElement">[0, 1, 2]<br />[0, 1, 3]<br />[0, 1, 4]<br />[0, 1, 5]<br />[0, 2, 3]<br />[0, 2, 4]<br />[0, 2, 5]<br />[0, 3, 4]<br />[0, 3, 5]<br />[0, 4, 5]<br />[1, 2, 3]<br />[1, 2, 4]<br />[1, 2, 5]<br />[1, 3, 4]<br />[1, 3, 5]<br />[1, 4, 5]<br />[2, 3, 4]<br />[2, 3, 5]<br />[2, 4, 5]<br />[3, 4, 5]<br /></pre>The output lends itself to a simple and nice iterative algorithm, I'll follow up on.<br /><br />The interesting follow up to combinatorial generation algorithms is using ranking and unranking. At this point, I think we need a O(n) to identify if two combinations are the same -- given in any order of elements. For example to compare $\{1, 2, 3\}, \{1, 3, 2\}, \{2, 1, 3\}, \{3, 1, 2\}, \{2, 3, 1\}, \{3, 2, 1\}$ we need to identify them and associate the same rank with them. I think for a subset of size $k$, the cost of ranking is $\theta(k)$, but I need to see if there is a better way to do it. <br /><br /><br /></div></div>Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com0tag:blogger.com,1999:blog-6194839.post-16189712868514136592016-07-01T18:51:00.001+05:302016-07-01T18:51:10.238+05:30Thoughts on Agile programming - team size<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on">I've been thinking about this for a very long time. What would be an ideal agile team size -- what would be a core team size to be more precise. I've been told in the past that it's 5, but I think it's 4 and here is how I think the team should be organized<br /><br /><table> <tbody><tr><th>Role</th><th>Role</th><th>Role</th><th>Role</th></tr><tr><td>Developer<sub>1</sub></td><td>Developer<sub>2</sub></td><td>Reviewer/Test<sub>1</sub></td><td>Reviewer/Test<sub>2</sub></td></tr></tbody></table></div>Here Reviewer/Tester and Developers should exchange roles if required and be flexible to work both ways for maximum efficiency. Note the role of Reviewer/Tester could be easily done by another Developer.<br /><br />Here is how I would schedule their interactions<br /><br /></div><table><tbody><tr><th>Day</th><th>Room<sub>1</sub></th><th>Room<sub>2</sub></th></tr><tr><td>1</td><td>Developer<sub>1</sub> and Reviewer/Test<sub>1</sub></td><td>Developer<sub>2</sub> and Reviewer/Test<sub>2</sub></td></tr><tr><td>2</td><td>Developer<sub>2</sub>, Developer<sub>1</sub> and Reviewer/Test<sub>1</sub></td><td>Reviewer/Test<sub>2</sub></td></tr><tr><td>3</td><td>Developer<sub>2</sub>, Developer<sub>1</sub> and Reviewer/Test<sub>2</sub></td><td>Reviewer/Test<sub>1</sub></td></tr><tr><td>4</td><td>Reviewer/Test<sub>2</sub>, Developer<sub>1</sub> and Reviewer/Test<sub>1</sub></td><td>Developer<sub>2</sub></td></tr><tr><td>5</td><td>Reviewer/Test<sub>2</sub>, Developer<sub>1</sub> and Reviewer/Test<sub>2</sub></td><td>Developer<sub>1</sub></td></tr><tr><td>6</td><td>Developer<sub>2</sub>, Developer<sub>1&nbsp;</sub>Reviewer/Test<sub>2</sub> and Reviewer/Test<sub>1</sub></td></tr></tbody></table><br />Teams will think I am crazy for suggesting working 6 days a week, this problem can be resolved by splitting day 6 into some hours each day. For example 1.5 hours a day could be kept aside each day for the developers/reviewer-tester to interact and day 6 could be eliminated all together<br /><br />In my scheme, each person gets a day/some time to themselves each week. All of them collaborate together and work together frequently. In this scheme indepedence is as important as the inter-dependance between each member<br /><br />What do you think?</div>Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com0tag:blogger.com,1999:blog-6194839.post-10575787482425798512016-07-01T18:27:00.001+05:302016-07-01T18:27:06.663+05:30Live patching on PPC64LE<div dir="ltr" style="text-align: left;" trbidi="on">Michael Ellerman has a great blog with all the technical details. There was a lot of work, brain storming and discussions involved. Check out&nbsp;<a href="http://mpe.github.io/posts/2016/05/23/kernel-live-patching-for-ppc64le/">http://mpe.github.io/posts/2016/05/23/kernel-live-patching-for-ppc64le/</a><br /><br /><br /></div>Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com0tag:blogger.com,1999:blog-6194839.post-91362942144124988572015-10-15T13:15:00.002+05:302015-10-15T13:15:45.800+05:30Some programming basics<div dir="ltr" style="text-align: left;" trbidi="on">As our programming knowledge grows, we sometimes forget that computers are not human. Although the incremental and consistent growth of AI techniques, mining may make us believe otherwise :) This is not a blog about AI or ML, but about some basics<br /><br />From my understanding of real numbers, I can easily postulate that<br /><br />0.1 + 0.1 = 0.2 -- (1)<br />and<br />0.1 + 0.1 + 0.1 = 0.3 -- (2)<br /><br />But for a computer formula (2) can be hard to comprehend and as a computer programmer we forget that from time to time<br /><br />I asked my python interpreter<br /><br />&gt;&gt;&gt; 0.1+0.1+0.1 == 0.3<br />False<br /><br />and later asked what is 0.1+0.1+0.1<br /><br />&gt;&gt;&gt; 0.1+0.1+0.1<br />0.30000000000000004<br /><br />Try this in your favorite language and see what you get -- the math underneath should be the same<br /><br />Reference - <a href="https://docs.python.org/2/tutorial/floatingpoint.html">https://docs.python.org/2/tutorial/floatingpoint.html</a></div>Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com0tag:blogger.com,1999:blog-6194839.post-30839815838878621942015-09-27T23:44:00.001+05:302015-09-27T23:44:30.642+05:30Some more interesting combinatorics<div dir="ltr" style="text-align: left;" trbidi="on">I tried to solve the following problems from the book by Lovasz and got wrong - well atleast the basic thinking was right :) <br /><br />Problem 1: We have $20$ different presents that we want to distribute to $12$ different children. It is not required that all children get something, it is possible that all presents are given to the same child. In how many ways can we distribute the presents?<br />Problem 2: We have $20$ kinds of presents with unlimited supply of each kind. We want to give this to $12$ children. It is not required that all children get something, it is possible that all presents are given to the same child. In how many ways can we distribute the presents?<br /><br />What do you think the answers are?</div>Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com0tag:blogger.com,1999:blog-6194839.post-32573539703160311282015-01-12T21:30:00.000+05:302015-01-12T21:30:12.870+05:30Happy New Year 2015<div dir="ltr" style="text-align: left;" trbidi="on">A happy/prosperous/safe/healthy new year to one and all. 2014 has been great, but also unexpected. My home Linux box crashed and I was forced to move to my MAC-MINI for my day-to-day work. Hopefully this year, I'll buy a good machine and get back to Linux soon. Desktops are getting harder to find and maintain (in terms of space), but still the best option IMHO. The sound of the spinning hard drive, powering on the desktop after a long vacation is just too much of fun to miss. My last desktop was AMD based, I have to move to Intel, may be I'll wait a bit more. May be I'll get lucky and someone will send me new cool hardware for free to hack on :) Hint, Hint!<br /><br />I did not mean to make this about my need for new compute. Here are my predictions for 2015/16 (yeah.. a bit more)<br /><br /><br /><ol style="text-align: left;"><li>Data center compute will get interesting with new processors and workloads</li><li>OS Wars will light up again</li><li>Children/Kids will get earlier access to computers and buy more hardware</li><li>Internet and bandwidth consolidation will across several devices - phone/computer/TV</li><li>People will start paying for cloud storage, storage is now a key bottleneck</li><li>MAC OS will continue to gain desktop share</li></ol><div>I am avoiding any security based predictions, you can guess why? I'll revise these soon, some time in Q2 this year</div><br /><br /><br /></div>Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com0tag:blogger.com,1999:blog-6194839.post-80872044836963323862014-10-07T22:51:00.001+05:302014-10-07T22:51:17.400+05:30Quick Review - The race of my life<div dir="ltr" style="text-align: left;" trbidi="on"><div class="separator" style="clear: both; text-align: center;"><a href="http://upload.wikimedia.org/wikipedia/en/0/0f/The_Race_of_My_Life.jpeg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://upload.wikimedia.org/wikipedia/en/0/0f/The_Race_of_My_Life.jpeg" height="320" width="207" /></a></div>I just finished reading Milkha's autobiography - The race of my life. I loved the simple writing and the length of the book. I must confess that having seen the movie earlier made it easier for me to read the book, however the movie and the book do not map 1:1.<br /><br />Milkha's book is filled with a story of tragedy of the bloody partition, determinism of a father to educate a child, hardwork and struggle of the youth of Milkha and his progress from an Army Jawan to almost a lieutenant, his days as sports administrator and his feelings for the current state of sports.<br /><br />All the events in which he participated, the cultural gaps between India and the rest of the world and his ability to learn &amp; improve and work hard with the coaches is clearly demonstrated. They are some hilarious moments about his sister Isher thinking he was shot during a race :)<br /><br />A great read, should not take you very long to complete and you'll end up feeling motivated to reach your goals.</div>Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com0tag:blogger.com,1999:blog-6194839.post-3008762356195381322014-08-17T22:14:00.002+05:302014-08-17T22:14:43.064+05:30Math by brute force<div dir="ltr" style="text-align: left;" trbidi="on">I came across a problem in a book on Combinatorics<br /><br />In how many ways can 5 gentleman and 3 ladies be seated such that no two ladies sit next to each other?<br /><br />The book's answer was 5!. Clearly not very believable, I decided to warm myself up and try and find an answer.<br /><br />My first answer was<br /><br />8! - 2.7! - 6.6!<br /><br />Something did not seem right, so I decided to use brute force. I wrote quick python code to list 8! permutations (all of them) and discard positions with two ladies together (yes, I permuted classes with numbers and types). The answer was 14400. Clearly I missed something and the computer cannot be wrong - well brute force is usually slow but right :)<br /><br />A little more thought and use of common sense got me to the right answer<br /><br />8! - (3 C 2)*2*7!&nbsp;+ 6.6! (via inclusion/exclusion principle)<br /><br />I am so excited to use brute force to check my answers - do you?<br /><br /><br /><br /><br /></div>Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com0tag:blogger.com,1999:blog-6194839.post-24018219368701094102014-05-23T08:05:00.002+05:302014-05-23T08:05:15.803+05:30Lessons learnt - cheap Android devices<div dir="ltr" style="text-align: left;" trbidi="on">One of the best things about an Android device is that it comes in various form factors and various price ranges. Over the years I've bought close to 6 Android devices. My first device was expensive and had no GPU hardware. I could not play games on it, so I decided to move to another one. This time I got a Nexus 4 as a gift<br /><br />Then I decided to buy a device from an Indian manufacturer with a quad-core CPU/1GB RAM/GPU and a decent display resolution with a 5" screen (<a href="http://www.karbonnmobiles.com/karbonn-TITANIUMS5Plus-proid-202.html">Karbonn S5</a>). The device was cheap and I could not help but compare the device and be delighted with my purchase. Over the year of usage of this device, I learnt my lesson<br /><br /><br /><ol style="text-align: left;"><li>There are absolutely no updates for the device - why do I care, what this meant is that I was left open to <a href="http://xkcd.com/1353/">OpenSSL heartbleed</a>.</li><li>The phone's hardware, touch screen started failing, some areas stopped responding</li><li>The firmware on the phone was signed using test-keys. A lot of useful software started detecting the phone as rooted :)</li><li>The key bottleneck for most software is not number of CPU's, but the amount of RAM/Speed of the processor and the quality of the GPU</li></ol><br /><br /><b>Lesson learnt - buy a phone with good reliable hardware and frequent updates, use the cheap ones for experimentation and development</b><br /><br />The good news is that since the hardware was cheap, I could easily replace it and keep the phone to try a <a href="http://www.cyanogenmod.org/">cyanogenmod</a> upgrade on it. Can't do much about the bad hardware though except use it as a device to try experiments on :)<br /><br /></div>Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com0tag:blogger.com,1999:blog-6194839.post-22459068061820007162013-12-11T21:26:00.002+05:302013-12-11T21:26:46.214+05:30Interesting combinatorics problem<div dir="ltr" style="text-align: left;" trbidi="on">I saw this problem in an old book on combinatorics I had, it took me a while to solve, but it is easy if you are familiar with the work of Euler.<br /><br /><b>Prove that an even length palindrome of integers is divisible by 11</b><br /><b><br /></b>If you know the answer - post it in the comments. If not, wait for a post by me :)</div>Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com0tag:blogger.com,1999:blog-6194839.post-44966195697639464452013-10-28T13:12:00.001+05:302013-10-28T13:12:24.523+05:30My first useful JavaScript program<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on">I was recently going through my son's workbook and it had an interest way of teaching addition - probably the Montessori method. The idea was to create a table of sum's of a few numbers and color numbers to see a pattern. I was quite amused and decided to see if I could write the code in JavaScript, a language I am trying to learn, I am going to do some additional work like graphical Towers of Hanoi with it as well, but for now I wanted to start simple<br /><br />Guess what - I succeeded in writing what I consider as a useful program (although I wrote it quite badly)<br /><br />Here is the code<br /><script src="https://gist.github.com/bsingharora/f11da47a00a3dd026e5f.js"></script>Here is the Javascript <script src="https://gist.github.com/bsingharora/0a5cc16ec9892292927e.js"></script>Here is the output<br /><br /><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-aUtt58Tplo4/Um34RpKUiFI/AAAAAAAAGyM/uyJl9CRGZDY/s1600/Screenshot+from+2013-10-28+11:07:55.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://3.bp.blogspot.com/-aUtt58Tplo4/Um34RpKUiFI/AAAAAAAAGyM/uyJl9CRGZDY/s320/Screenshot+from+2013-10-28+11:07:55.png" width="248" /></a></div><br /><br /><br /><br /></div></div></div></div></div></div></div>Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com0tag:blogger.com,1999:blog-6194839.post-81715383941758900612013-10-11T08:37:00.001+05:302013-10-11T08:37:26.438+05:30Your code is only as good as the tests you run on it<div dir="ltr" style="text-align: left;" trbidi="on">Computer programs have an interesting well known quality - even incorrect programs can produce the desired output for a subset of inputs. I recently re-learnt this while doing my graphical convex hull implementation<br /><br />I started with a test strategy of random test generation. Use &nbsp;a good random number generator to generate<br /><br /><ol style="text-align: left;"><li>Number of random points as input</li><li>The random points themselves</li></ol><br /><br />This strategy helped me test the program from crashes/instability and showed a potential functional issue that showed up when a large number of points were generated. See the diagram below<br /><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-h6PCkZEsGx0/UldlygmiD3I/AAAAAAAAGu8/DguwQ9uLcZU/s1600/brokenhull.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://4.bp.blogspot.com/-h6PCkZEsGx0/UldlygmiD3I/AAAAAAAAGu8/DguwQ9uLcZU/s320/brokenhull.png" width="320" /></a></div>Can you spot the problem? I now need a specific test case to isolate the problem, random inputs did not provide the necessary clue with smaller inputs. Luckily for me, I found a good set of inputs at&nbsp;<a href="http://stackoverflow.com/questions/482278/test-case-data-for-convex-hull">http://stackoverflow.com/questions/482278/test-case-data-for-convex-hull</a><br /><br />I ran three test cases and found the first two ran fine<br /><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-YMIBYWPs3DM/UldlymSZueI/AAAAAAAAGvA/eRa8NJc3knY/s1600/test1cv.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://4.bp.blogspot.com/-YMIBYWPs3DM/UldlymSZueI/AAAAAAAAGvA/eRa8NJc3knY/s320/test1cv.png" width="320" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-3vvBcyiyISo/UldlykgxolI/AAAAAAAAGvQ/AGbyxrk0kXA/s1600/test2cv.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://4.bp.blogspot.com/-3vvBcyiyISo/UldlykgxolI/AAAAAAAAGvQ/AGbyxrk0kXA/s320/test2cv.png" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: left;">The third one was a hit, it broke my algorithm</div><div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-6Z4i3tnMC6I/Uldltu0nn6I/AAAAAAAAGu0/IxhKuInAkak/s1600/brokenhull2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://1.bp.blogspot.com/-6Z4i3tnMC6I/Uldltu0nn6I/AAAAAAAAGu0/IxhKuInAkak/s320/brokenhull2.png" width="320" /></a></div><div class="separator" style="clear: both; text-align: left;">Beautiful visualization, but the code was clearly broken. After looking at the diagram and looking at the code, I realized that I was not handling co-linear points correctly. Finally, I got</div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-7p7g18KIu5I/UldlzByVpQI/AAAAAAAAGvU/vFHMP3KSqMU/s1600/test3cv.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="http://1.bp.blogspot.com/-7p7g18KIu5I/UldlzByVpQI/AAAAAAAAGvU/vFHMP3KSqMU/s320/test3cv.png" width="320" /></a></div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;">Now, I am back to the random testing strategy and have gotten satisfactory results so far</div><div class="separator" style="clear: both; text-align: left;"><br /></div><div class="separator" style="clear: both; text-align: left;">NOTE: My test feedback strategy is based on visualization, one could even automate the tests</div></div>Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com0tag:blogger.com,1999:blog-6194839.post-57783029682770511972013-09-25T08:41:00.001+05:302013-09-25T08:41:16.028+05:30Who inspires you?<div dir="ltr" style="text-align: left;" trbidi="on">Many of us are inspired by role models around us, in person, in media, in history, men and women who lead by example. I remember an instance - a colleague of mine was asked about role models and he was selected because he mentioned his grandfather. Other colleagues who mentioned names like Mahatma Gandhi were rejected, because in the HR's mind, a role model has to be someone you personally know. I felt those were very strong opinions to make a judgement for employment<br /><br />In the past, I've had several role models<br /><br /><br /><ul style="text-align: left;"><li>My dad - for simplicity, integrity and courage to do the right thing and caring for others. Ability to network, empathize. Social causes and care for poor.</li><li>My mom - for her ability to manage so many things, manage the family, swiftness, love and extreme courage. Her ability to network</li><li>Mahatma Gandhi - For large traits of what I saw in my dad.</li><li>Don Knuth - For being so nice, smart and humble</li><li>Ex-leads - technical leads in my first job, software architects, distinguished engineers from whom I've learnt a lot. Learnt virtues of caring for people beyond the scope of work.</li><li>Relatives and friends - who've stood by thick and thin, good and bad times</li></ul><div>Today I was inspired by our security guard. His simplicity, his dedication to work and sincerity inspired me. I write this blog and dedicate it to all those who inspired me. I think we don't need to look very far for inspiration, it is right around the corner, in my case right at my doorstep.</div><div><br /></div><div>I hope all of us find many role models who inspire us to do the right thing for ourselves and the society we build together.</div><div><br /></div><br /><br /></div>Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com0tag:blogger.com,1999:blog-6194839.post-60277455734539255642013-09-19T08:28:00.003+05:302013-09-19T08:28:28.983+05:30The call for better reading/writing skills<div dir="ltr" style="text-align: left;" trbidi="on">I am sure you've faced it and done it to others - <b>not read</b> the <b>entire email in totality</b> or communication in full and <i>missed parts</i> of it. With the abundance of information comes the challenge for the new age of engineers to read and parse information completely. There is a challenge that people writing blog posts such as me, do a good job of delivering the information in manner that key points are not missed<br /><br /><h3 style="text-align: left;">Summary of the problem</h3><br /><ul style="text-align: left;"><li>Of late, I've seen people ask questions already answered in the email they are replying too</li><li>People chain emails expecting everybody to read things top to bottom</li><li>Most people reply on top of emails. Top Posting</li></ul><br /><br />I think the open source community solved this problem with rules and netiquettes, but most of us who are not aware of them - fail to see the importance of communicating clearly so as to get maximum retention benefits from the audience of the communication.<br /><br /><h3 style="text-align: left;">In my mind, here are the best practices</h3><br /><br /><ul style="text-align: left;"><li>Make sure that the key information is not hidden in a paragraph, but upfront</li><li>Try to summarize, re-emphasize</li><li>Use best practices, netiquettes</li><li>Don't forward or reply to long chains, clearly snip out irrelevant content</li><li>Use smart subjects</li><li>Highlight important points</li></ul><br /><br /><h3 style="text-align: left;">If you are on the receiving side</h3><br /><br /><ul style="text-align: left;"><li>Spend some time on important emails, if required re-read</li><li>Try to limit the amount of emails you read - batch process, don't switch too often</li><li>Remember, email is official communication</li></ul><br /><br /></div>Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com0tag:blogger.com,1999:blog-6194839.post-61244805721128450932013-09-18T20:36:00.003+05:302013-09-18T20:38:12.488+05:30A poor way to do sorting in an OO language (java)<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on">Going back to Java after so many years is an interesting experience. I made the classic rookie mistake with implementation of a sorting library. All good programming practices tell you that manipulation methods on a collection should always be static and not bound to the class. To top it all, this was the first time I was using generics after spending some time reading about them :)<br /><br />I had done things the other way around, almost as if I had implemented a stack with data. My ego was too big for me not to succeed with that technique. Here is an implementation of selection sort. Below is what I ended up implementing<br /><br /><pre>/**<br /> *<br /> * @author balbir<br /> * @param <item><br /> */<br />public class SelectionSort &lt; Item extends Comparable &gt;<item comparable="" extends=""><item comparable="" extends=""><item comparable="" extends=""> {<br /> private Item[] elements;<br /> SelectionSort(int N)<br /> {<br /> elements = (Item[]) new Comparable[N]; <br /> }<br /><br /> public void sort()<br /> {<br /> int min;<br /> for (int i = 0; i &lt; elements.length; i++)<br /> {<br /> min = i;<br /> for (int j = i+1; j &lt; elements.length; j++)<br /> {<br /> if (elements[j].compareTo(elements[min]) &lt; 0)<br /> min = j;<br /> }<br /> Item tmp;<br /> tmp = elements[i];<br /> elements[i] = elements[min];<br /> elements[min] = tmp;<br /> <br /> }<br /> }<br /> <br /> public void dump()<br /> {<br /> for (int i = 0; i &lt; elements.length; i++)<br /> System.out.print(elements[i] + " ");<br /> System.out.println();<br /> }<br /> <br /> public void load(Item a[])<br /> {<br /> for (int i = 0; i &lt; elements.length; i++)<br /> elements[i] = a[i];<br /> }<br /> <br /> /**<br /> * @param args the command line arguments<br /> */<br /> public static void main(String[] args) {<br /> // TODO code application logic here<br /> Integer[] a = {1, 2, -1, 3, 0, 5, 7, 9, 4};<br /> SelectionSort<integer> s = new SelectionSort<integer>(a.length);<br /> s.load(a);<br /> s.dump();<br /> s.sort();<br /> s.dump();<br /> }<br /> <br />}<br /><br /></integer></integer></item></item></item></item></pre><div><br /></div><div>It is funny how I had to use a load class to get the data and call the sort method. What a bad decision, the reason I shared this post is just to show that with generics one can indeed mix classes and class templates. I for example mixed Integer and Comparable and the default implementation worked.</div><div><br /></div></div></div></div></div>Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com0tag:blogger.com,1999:blog-6194839.post-9971380482607351132013-08-04T22:23:00.003+05:302013-08-04T22:23:54.914+05:30I keep going back to concrete math, but this time I went with a tool<div dir="ltr" style="text-align: left;" trbidi="on">Of late, I seem to be stuck in a loop with books. I read parts of them and then seem to come back to the very beginning of the same book and discover something new. I am stuck in a partial loop in an "open form". Of late that has happened with <a href="http://www.amazon.in/Concrete-Mathematics-Foundation-Computer-Science/dp/8131708411/ref=sr_1_1?ie=UTF8&amp;qid=1375634416&amp;sr=8-1&amp;keywords=concrete+mathematics">Concrete Mathematics</a>. I started with the first chapter on Recurrent problems - you seen the irony :)<br /><br />Anyway, one of the problems is Towers of Hanoi with limitation. Don't go to the intermediate peg directly, go to the destination peg and then go to the intermediate peg. I remember reading somewhere that Knuth used Macsyma for a bunch of verification on Metafont (I could be wrong). I decided to use <a href="http://maxima.sourceforge.net/">Maxima</a>. I used the solve_rec procedure<br /><br /><span style="font-family: Courier New, Courier, monospace;">load(solve_rec);</span><br /><br />The recurrence equation is<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-84RiTG62ZKc/Uf6Gf0DGh7I/AAAAAAAAGJM/QLgDYQnxn6o/s1600/img1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-84RiTG62ZKc/Uf6Gf0DGh7I/AAAAAAAAGJM/QLgDYQnxn6o/s1600/img1.png" /></a></div><br /><span style="font-family: Courier New, Courier, monospace;">solve_rec(a[n] = 3*a[n-1] + 1, a[n]));</span><br /><br /><br />and Maxima was quick to respond with the answer<br /><div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-ntppYVeBXNI/Uf6GfyhTVDI/AAAAAAAAGJQ/z85qf_Fd1Fc/s1600/img2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-ntppYVeBXNI/Uf6GfyhTVDI/AAAAAAAAGJQ/z85qf_Fd1Fc/s1600/img2.png" /></a></div><br />I wonder if Knuth is right, in the future most of the burden of mathematical complexity of finding a solution will be delegated to computers.</div>Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com0tag:blogger.com,1999:blog-6194839.post-26812748491456927872013-08-04T20:12:00.003+05:302013-08-04T20:12:33.937+05:30Fedora 17 EOL<div dir="ltr" style="text-align: left;" trbidi="on">For those who missed it, the notification is at&nbsp;<a href="https://lists.fedoraproject.org/pipermail/announce/2013-July/003177.html">Fedoa 17 EOL announcement</a>. Looks like I'll be forced to upgrade :)</div>Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com0tag:blogger.com,1999:blog-6194839.post-47863294519332579012013-02-03T09:30:00.001+05:302013-02-03T09:30:56.765+05:30My prediction for the new wave of consumer electronics<div dir="ltr" style="text-align: left;" trbidi="on">Remember the time when new laptops/desktops were fun to have. A laptop was a must have for college (I never had one, but thanks to my brother I had a great computer, where I learnt all my programming). The new rage is now the new era of merged functionality<br /><br /><br /><ul style="text-align: left;"><li>Mobile</li><li>Photos</li><li>Email</li><li>Maps &amp; GPS</li><li>Games</li><li>Internet browsing</li><li>Video calling</li></ul><br /><br />The gadgets out there are amazing, to be honest I own quite a few of them. I've had a prediction for a while on what would happen next (happen next to the laptop/notebook world). Lets look at the pros and cons of the mobile computing era devices versus laptop/desktop world<br /><br /><b>Pros</b><br /><br /><ol style="text-align: left;"><li>Easier to carry around</li><li>Single device to carry (integrated functionality)</li><li>Cheaper software licensing cost (games for $5, etc)</li><li>Touch capability (better user experience)</li><li>Growing compute and memory capacity</li></ol><br /><br /><b>Cons</b><br /><br /><ol style="text-align: left;"><li>Limited storage</li><li>More frequent recycling</li><li>Not upgradable in any sense</li><li>Faster obsolescence</li><li>Harder to create content (programming to be done on laptops/desktops, documents are hard to create)</li><li>Very limited screen size</li></ol><br /><br /><br />Gadgets are fun and most people don't care about limited storage today or content creation, but limited storage along with faster obsolescence along with limited ability to create content will help the desktop/laptop world emerge back.<br /><div><br /></div><br /><b>My&nbsp;prediction&nbsp;based limited storage and changing laptop world (touch screen) is that the laptop world will emerge back and win again.</b><br /><br /><br /><br /></div>Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com1tag:blogger.com,1999:blog-6194839.post-86509049369864688852013-01-27T23:41:00.001+05:302013-01-27T23:42:25.648+05:30Operating Systems and their UI era<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: Times, Times New Roman, serif;">This afternoon as I had free time to ponder on something totally unrelated to the need of the hour, I was thinking of user interface evolution through time. I'd like to quickly classify them as</span><br /><span style="font-family: Times, Times New Roman, serif;"><br /></span><span style="font-family: Times, Times New Roman, serif;">1. *NIX era</span><br /><span style="font-family: Times, Times New Roman, serif;">2. Desktop era//Gaming console era</span><br /><span style="font-family: Times, Times New Roman, serif;">3. Mobile device/Tablet/Cloud computing</span><br /><span style="font-family: Times, Times New Roman, serif;"><br /></span><span style="font-family: Times, Times New Roman, serif;"><b>NOTE</b>: *NIX/Desktop and Mobile devices do co-exist today, but the era classification is based on popularity as read through magazine articles/online and casual discussions</span><br /><span style="font-family: Times, Times New Roman, serif;"><br /></span><span style="font-family: Times, Times New Roman, serif;">The first *NIX era was a terminal era, with limited terminals (remember the phosphor screens) and wonderful keyboards that lacked (arrow keys, I just have to assume looking at the design of the original vi). The UI was quite straight forward (text), of course there were some high end workstations as time evolved. The most popular *NIXes were BSD and AT&amp;T variants</span><br /><span style="font-family: Times, Times New Roman, serif;"><br /></span><span style="font-family: Times, Times New Roman, serif;">The desktop era started with the PC and DOS. Keyboards were designed for non programmers, they were friendlier. With the introduction of GUI OS's, mice and keyboard were the primary input devices (supplemented by new generation pen &amp; other new input techniques, but the focus was mice and keyboard). They had good GUI's, nice video and sound cards and were optimized for keyboard and mice. This lead to a sporadic growth in Internet usage, gaming. DOS/Windows/OS-X and MAC-OS variants with new design inspired from *NIX, but still different were the ruling OSes. *NIX were pushed to large systems where they would continue to run and serve large workloads as before.</span><br /><span style="font-family: Times, Times New Roman, serif;"><br /></span><span style="font-family: Times, Times New Roman, serif;">The latest trend is mobile/tablet computing, this is again a market captured back by variants of *NIX (Linux - Android) and iOS (BSD) variants. Touch screen with LCD front ends with gesture awareness and multiple sensors are dominant UI inputs. It is good to see OS's designed on older principles race into the new era where voice input/GPS sensors/Cameras/touch screens/gestures are the primary interaction points with a lot of automation and simplicity built into the software on top of them. As I write, these devices are making their way into gaming consoles as well. These workloads are well supported in the back end with cloud computing work flows that provide the necessary horse power for calculating complex map routes, document editing and much more (most of these are again based on Linux servers).</span><br /><span style="font-family: Times, Times New Roman, serif;"><br /></span><span style="font-family: Times, Times New Roman, serif;">I suspect the next generation will be projector driven devices, it will be interesting to see how *NIX variants will drive the next generation of computing devices.</span></div>Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com0tag:blogger.com,1999:blog-6194839.post-914200059111783802012-09-03T08:01:00.001+05:302012-09-03T08:01:28.265+05:30Algorithms beyond school<div dir="ltr" style="text-align: left;" trbidi="on">I was working on a list of algorithms a new college graduate ought to know to either<br /><br /><ul style="text-align: left;"><li>Do well in an interview</li><li>Make quick progress through the learning curve</li></ul><br />Here is the list I have so far, I would appreciate comments on what else to add<br /><br /><ol style="text-align: left;"><li>Population Counting</li><li>Multi-precision Arithmetic</li><li>Fast Fourier Transform</li><li>Fast Prime Number Generation</li><li>Quicksort</li><li>Union-Find</li><li>String searching (KMP, Regular Expressions)</li><li>Polynomial Multiplication</li><li>Calculation of Pi</li><li>8 Queens Problem</li><li>Instance of a turing machine simulation</li><li>Tries</li><li>Radix Tree</li><li>Red Black Tree</li><li>Huffman's algorithm</li><li>Graphs - DFS, BFS</li><li>Graphs - Bipartite</li><li>Minimum Spanning Tree</li><li>Hashing algorithms </li><li>Linear programming?</li><li>Classes of problems - P/NP/?</li><li>Vertex Cover?</li><li>Synchronization (locks/mutex/spin locks)</li><li>Lockless algorithms</li></ol>How does the list look? <br /><br /><br /><br /></div>Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com1tag:blogger.com,1999:blog-6194839.post-56121662694782055682012-06-29T20:28:00.000+05:302012-06-29T20:32:04.314+05:30Power of programming - online<div dir="ltr" style="text-align: left;" trbidi="on">An article of mine got posted online, check out&nbsp;<a href="http://www.linuxforu.com/2012/06/power-programming-bitwise-tips-tricks/">http://www.linuxforu.com/2012/06/power-programming-bitwise-tips-tricks/</a></div>Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com0tag:blogger.com,1999:blog-6194839.post-59345591356029797262012-04-19T21:24:00.001+05:302012-04-19T21:25:53.169+05:30A night that stole more than just my sleep<div dir="ltr" style="text-align: left;" trbidi="on"><h6 class="uiStreamMessage" data-ft="{&quot;type&quot;:1}" style="font-family: Verdana,sans-serif; font-weight: normal;"> <span class="messageBody" data-ft="{&quot;type&quot;:3}" style="font-size: small;"><div class="text_exposed_root text_exposed" id="id_4f903446144564392915976">What a night.. I lost all useful data on my desktop due to (a) lack of sleep (b) eagerness to install Fedora 17 Beta. How this happened is a long story, but here is the sequence of events<br /><br /><ol style="text-align: left;"><li>I saw Fedora 17 Beta (got excited with the new release features)</li><li>Got excited and upgraded my Fedora 15 (that I had maintained since Fedora 10 and kept doing upgrades) to Fedora 17</li><li>Neither <span class="text_exposed_show">ATI proprietary nor the open source drivers work</span></li><li><span class="text_exposed_show"> I decide to reinstall Fedora - Except that I used my home partition as root partition. I've lost all my scanned documents, my open source repositories (so many of them) :(. My programming, my SDK's, my projects, my articles, my documents, my downloads... I am going to cry. Moral of the story, backup is not for dummies, it is for everyone! Anyway, I am too arrogant to backup, even now :) Leave me alone!</span></li><li><span class="text_exposed_show"> On the reinstalled partition, I am back to (c)</span></li><li><span class="text_exposed_show"> Today, after extensive debugging I find out all my xorg.conf hacks don't work -- why? Apparently X has gotten smarter and needs additional options to enable specific monitor sections in xorg.conf to a specific output. By default all my configuration was being applied to my HDMI output.</span></li><li><span class="text_exposed_show"> I figure it out, fix the display and now I am back to starting off from lot of empty space and this post.</span></li><li><span class="text_exposed_show"> Thank god, I use some tools to keep my web data in sync and have backup of some key things (Oh! come on, everyone knows I was lying.. I do maintain backups on USB sticks once in a while, but not enough to stop complaining, yes I still lost all my data). Confused?</span></li></ol><span class="text_exposed_show"> <br /> There you have it, thanks for reading my rant.. now back to work!</span></div></span></h6></div>Balbir Singhhttps://plus.google.com/102145933447820869205noreply@blogger.com0