<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8220923316510870669</id><updated>2019-01-25T18:57:53.683+05:45</updated><category term="C Tutorial"/><category term="Cplusplus Tutorial"/><category term="Data Structure and Algorithm"/><category term="Advanced C Tutorial"/><category term="Numerical Methods"/><category term="GLUT Tutorial"/><category term="Computer Graphics"/><category term="PHP Tutorial"/><category term="Image Processing"/><category term="Android Application Development"/><category term="PROLOG"/><category term="C Projects"/><category term="cplusplus projects"/><category term="Artificial Intelligence"/><category term="Graphics Libraries"/><category term="Assembly Tutorials"/><category term="Javascript Tutorial"/><category term="Linux"/><category term="Machine Learning"/><category term="Business Intelligence"/><category term="Data Analysis"/><category term="Database"/><category term="R"/><title type='text'>Programming Techniques</title><subtitle type='html'>Tutorials and Mini Projects of C, C++, PHP, OpenGL,  and other languages with C/C++ codes of Data Structure, Numerical Methods and Computer Graphics</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default?start-index=26&amp;max-results=25'/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>243</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-6749457723575137757</id><published>2017-11-06T13:54:00.002+05:45</published><updated>2017-11-06T13:54:44.018+05:45</updated><category scheme="http://www.blogger.com/atom/ns#" term="Advanced C Tutorial"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure and Algorithm"/><title type='text'>RSA Algorithm Explained with C code</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;An RSA algorithm is an important and powerful algorithm in cryptography. It is widely used in Digital Signature and in an SSL.  The algorithm works in the following way&lt;br&gt;&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Select at random two LARGE prime number $p$ and $q$.&lt;/li&gt;&lt;li&gt;Multiply $p$ and $q$ i.e. $n = p*q$.&lt;/li&gt;&lt;li&gt;Select a small odd integer $e$ which is relatively prime to $\phi(n)$, where $\phi(n) = (p-1) * (q - 1)$.&lt;/li&gt;&lt;li&gt;Calculate the value of $d$ (explained below). $d$ is calculated as a modular multiplicative inverse of $e$ modulo $n$.&lt;/li&gt;&lt;li&gt;Publish the pair $P = (e, n)$ as a public key. &lt;/li&gt;&lt;li&gt;Keep secret the pair $S = (d, n)$ as a private key. &lt;/li&gt;&lt;/ol&gt;&lt;div&gt;The message is encrypted using $P = (e, n)$ using following formula. &lt;/div&gt;&lt;/div&gt;&lt;div&gt;\[P(M) = M^e \text{ mod } n\]&lt;/div&gt;&lt;div&gt;The message can be decrypted using $P = (d, n)$ using following formula.&lt;/div&gt;&lt;div&gt;\[S(C) = C^d \text{ mod } n\]&lt;/div&gt;&lt;div&gt;Secret key pair $(d, n)$ should be kept secret.&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;a href=&quot;https://www.programming-techniques.com/2017/11/rsa-algorithm-explained-with-c-code.html#more&quot;&gt;Read more »&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/6749457723575137757/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2017/11/rsa-algorithm-explained-with-c-code.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/6749457723575137757'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/6749457723575137757'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2017/11/rsa-algorithm-explained-with-c-code.html' title='RSA Algorithm Explained with C code'/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-3743924936943115351</id><published>2017-11-06T08:43:00.002+05:45</published><updated>2017-11-06T08:43:14.217+05:45</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure and Algorithm"/><title type='text'>Calculation of Modular Exponentiation in C</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Modular Exponentiation takes the following form.&lt;br&gt;\[A = B^C \text{ mod } D\]&lt;br&gt;Efficient calculation of modular exponentiation is critical for many cryptographic algorithms like RSA algorithm. The following program calculates the modular exponentiation. The method of repeated squaring solves this problem efficiently using the binary representation of C.&lt;br&gt;&lt;br&gt;This code is also available on &lt;a href=&quot;https://github.com/Bibeknam/programming-techniques/blob/master/NumberTheory/modular_exponentiation.c&quot; target=&quot;_blank&quot;&gt;GitHub&lt;/a&gt;.&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;a href=&quot;https://www.programming-techniques.com/2017/11/calculation-of-modular-exponentiation.html#more&quot;&gt;Read more »&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/3743924936943115351/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2017/11/calculation-of-modular-exponentiation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/3743924936943115351'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/3743924936943115351'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2017/11/calculation-of-modular-exponentiation.html' title='Calculation of Modular Exponentiation in C'/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-5670257913078819037</id><published>2017-11-05T14:41:00.000+05:45</published><updated>2017-11-05T14:41:43.585+05:45</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure and Algorithm"/><title type='text'>C Code For Solving Modular Linear Equations</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;a href=&quot;http://www.programming-techniques.com/2017/11/extended-euclids-algorithm-c-code.html&quot; target=&quot;_blank&quot;&gt;The Extended Euclid&amp;#39;s Algorithm&lt;/a&gt; solves the equation of the form&lt;br&gt;&lt;div&gt;\[ GCD(a, n) = d = ax + ny \]&lt;/div&gt;&lt;div&gt;If we multiply the both sides by &lt;i&gt;(mod n), &lt;/i&gt;we get&lt;/div&gt;&lt;div&gt;\[ ax + ny \equiv d (\text{ mod } n) \]&lt;/div&gt;&lt;div&gt;This is equivalent to,&lt;/div&gt;&lt;div&gt;\[ ax \equiv d (\text {mod } n)\]&lt;/div&gt;&lt;div&gt;In this article, I present a C Programming Code to solve this type of modular linear equation. &lt;/div&gt;&lt;div class=&quot;tips&quot;&gt;&lt;h3&gt;Congruence Modulo &lt;/h3&gt;You just saw a weird kind of mathematical expression of the form &lt;br&gt;\[ A \equiv B (\text { mod } C) \]&lt;br&gt;This says that A is congruent to B modulo C. What does it mean? Before I tell you the meaning of above operator, please note that this kind of expression is every common in number theory. If you are interested in Cryptography and starting to learn it, you will encounter this operator numerous time. Lets take an example,&lt;br&gt;\[ 21 \equiv 5 (\text { mod } 4) \]&lt;br&gt;A symbol $\equiv$ means &amp;quot;Equivalence&amp;quot;. In above equation, 21 and 5 are equivalent. This is because 21 modulo 4 = 1 is equal to 5 modulo 4 = 1. Another example is $51 \equiv 16 (\text{ mod } 7)$&lt;/div&gt;&lt;br&gt;The value of &lt;i&gt;x&lt;/i&gt; can be more than one depending upon the GCD of &lt;i&gt;a&lt;/i&gt; and &lt;i&gt;n&lt;/i&gt;. There are always &lt;i&gt;d&lt;/i&gt; number of solutions of &lt;i&gt;x&lt;/i&gt; where &lt;i&gt;d = GCD(a, n). &lt;/i&gt;If &lt;i&gt;a&lt;/i&gt; and &lt;i&gt;n&lt;/i&gt; are relatively prime i.e. GCD is 1, there is only one unique solution and this is very important for calculating secret key in RSA algorithm.&lt;br&gt;&lt;/div&gt;&lt;a href=&quot;https://www.programming-techniques.com/2017/11/c-code-for-solving-modular-linear.html#more&quot;&gt;Read more »&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/5670257913078819037/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2017/11/c-code-for-solving-modular-linear.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/5670257913078819037'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/5670257913078819037'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2017/11/c-code-for-solving-modular-linear.html' title='C Code For Solving Modular Linear Equations'/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-4531851618915789941</id><published>2017-11-05T14:05:00.000+05:45</published><updated>2017-11-07T07:29:44.001+05:45</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Tutorial"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure and Algorithm"/><title type='text'>Extended Euclid&#39;s Algorithm C Code</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Before going through this article, please look at my previous article about Euclid&amp;#39;s Algorithm. The Extended Euclid&amp;#39;s algorithm solves the following equation.&lt;br&gt;\[GCD(a, b) = d = ax + by\]&lt;br&gt;In addition to calculating a GCD, it calculates coefficients x and y such that satisfies the above equation. These coefficients x and y are important for calculating modular multiplicative inverses. The Extended Euclid&amp;#39;s algorithm is used in a much practical application specifically in cryptography.&lt;br&gt;&lt;br&gt;The following C code presents the efficient algorithm to solve Extended Euclid&amp;#39;s algorithm. The code is also available on &lt;a href=&quot;https://github.com/Bibeknam/programming-techniques/blob/master/NumberTheory/extended_euclid.c&quot; target=&quot;_blank&quot;&gt;GitHub&lt;/a&gt;.&lt;br&gt;&lt;/div&gt;&lt;a href=&quot;https://www.programming-techniques.com/2017/11/extended-euclids-algorithm-c-code.html#more&quot;&gt;Read more »&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/4531851618915789941/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2017/11/extended-euclids-algorithm-c-code.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/4531851618915789941'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/4531851618915789941'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2017/11/extended-euclids-algorithm-c-code.html' title='Extended Euclid&#39;s Algorithm C Code'/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-3917022937458493713</id><published>2017-11-05T13:52:00.001+05:45</published><updated>2017-11-05T13:52:34.743+05:45</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Tutorial"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure and Algorithm"/><title type='text'>Euclid&#39;s Algorithm C code </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Euclid&#39;s algorithm calculates the GCD (Greatest Common Divisor) for two numbers &lt;i&gt;a&lt;/i&gt; and &lt;i&gt;b&lt;/i&gt;. The following C program uses recursion to get the GCD.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The code is also available on &lt;a href=&quot;https://github.com/Bibeknam/programming-techniques/blob/master/NumberTheory/euclid.c&quot; target=&quot;_blank&quot;&gt;GitHub&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;pre class=&quot;brush:c&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;&lt;br /&gt;int euclid(int a, int b) {&lt;br /&gt; if (b == 0) {&lt;br /&gt;  return a;&lt;br /&gt; } else {&lt;br /&gt;  return euclid(b, a % b);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main(int argc, char* argv[]) {&lt;br /&gt; int a = 30, b = 21;&lt;br /&gt; printf(&quot;GCD is %d\n&quot;, euclid(a, b));&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/3917022937458493713/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2017/11/euclids-algorithm-c-code.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/3917022937458493713'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/3917022937458493713'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2017/11/euclids-algorithm-c-code.html' title='Euclid&#39;s Algorithm C code '/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-3968045994271484333</id><published>2017-10-23T23:08:00.000+05:45</published><updated>2017-10-23T23:08:23.959+05:45</updated><category scheme="http://www.blogger.com/atom/ns#" term="Advanced C Tutorial"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure and Algorithm"/><title type='text'>Fastest Fibonacci Sequence/Number Computation</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;The fastest way (in O(n)) of calculating Fibonacci sequence is by using matrix multiplication approach using following relation.&lt;br&gt;\[\begin{bmatrix}0 &amp;amp; 1 \\ 1 &amp;amp; 1 \end{bmatrix}^n = \begin{bmatrix} F_{n - 1} &amp;amp; F_n \\ F_n &amp;amp; F_{n + 1}\end{bmatrix}\]&lt;br&gt;Calculating $F_{34}$ is, therefore, multiplying the matrix $\begin{bmatrix}0 &amp;amp; 1 \\ 1 &amp;amp; 1\end{bmatrix}$ 34 times. The $a_{01}$ or $a_{10}$ gives the right fibonacci number. In fact $F_{34}$ can be calculated in less than 34 multiplication in following away.&lt;br&gt;\[ \begin{bmatrix} 0 &amp;amp; 1 \\ 1 &amp;amp; 1\end{bmatrix}^2 = \begin{bmatrix} 0 &amp;amp; 1 \\ 1 &amp;amp; 1\end{bmatrix} X \ \begin{bmatrix} 0 &amp;amp; 1 \\ 1 &amp;amp; 1\end{bmatrix} \\&lt;br&gt;\begin{bmatrix} 0 &amp;amp; 1 \\ 1 &amp;amp; 1\end{bmatrix}^4 = \begin{bmatrix} 0 &amp;amp; 1 \\ 1 &amp;amp; 1\end{bmatrix}^2 X \ \begin{bmatrix} 0 &amp;amp; 1 \\ 1 &amp;amp; 1\end{bmatrix}^2 \\&lt;br&gt;\begin{bmatrix} 0 &amp;amp; 1 \\ 1 &amp;amp; 1\end{bmatrix}^8 = \begin{bmatrix} 0 &amp;amp; 1 \\ 1 &amp;amp; 1\end{bmatrix}^4 X \ \begin{bmatrix} 0 &amp;amp; 1 \\ 1 &amp;amp; 1\end{bmatrix}^4 \\&lt;br&gt;\begin{bmatrix} 0 &amp;amp; 1 \\ 1 &amp;amp; 1\end{bmatrix}^{16} = \begin{bmatrix} 0 &amp;amp; 1 \\ 1 &amp;amp; 1\end{bmatrix}^8 X \ \begin{bmatrix} 0 &amp;amp; 1 \\ 1 &amp;amp; 1\end{bmatrix}^8 \\&lt;br&gt;\begin{bmatrix} 0 &amp;amp; 1 \\ 1 &amp;amp; 1\end{bmatrix}^{32} = \begin{bmatrix} 0 &amp;amp; 1 \\ 1 &amp;amp; 1\end{bmatrix}^{16} X \ \begin{bmatrix} 0 &amp;amp; 1 \\ 1 &amp;amp; 1\end{bmatrix}^{16} \\&lt;br&gt;\begin{bmatrix} 0 &amp;amp; 1 \\ 1 &amp;amp; 1\end{bmatrix}^{34} = \begin{bmatrix} 0 &amp;amp; 1 \\ 1 &amp;amp; 1\end{bmatrix}^{32} X \ \begin{bmatrix} 0 &amp;amp; 1 \\ 1 &amp;amp; 1\end{bmatrix}^{2} \\\]&lt;br&gt;This means, the multiplication can be done in logarithmic time. The C code for this computation is given below (also available on &lt;a href=&quot;https://github.com/Bibeknam/programming-techniques/blob/master/fibonacci_fastest.c&quot; target=&quot;_blank&quot;&gt;GitHub&lt;/a&gt;).&lt;br&gt;&lt;/div&gt;&lt;a href=&quot;https://www.programming-techniques.com/2017/10/fastest-fibonacci-sequencenumber.html#more&quot;&gt;Read more »&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/3968045994271484333/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2017/10/fastest-fibonacci-sequencenumber.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/3968045994271484333'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/3968045994271484333'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2017/10/fastest-fibonacci-sequencenumber.html' title='Fastest Fibonacci Sequence/Number Computation'/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-3335180775250344639</id><published>2017-10-19T12:20:00.000+05:45</published><updated>2018-10-19T13:13:50.715+05:45</updated><category scheme="http://www.blogger.com/atom/ns#" term="Advanced C Tutorial"/><category scheme="http://www.blogger.com/atom/ns#" term="Data Structure and Algorithm"/><title type='text'>Selection Algorithm (median of medians ) implementation in C</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;How do you find out a median of an array? If someone asks you this question, you will immediately say &amp;quot;First sort it and then find the $\left ( \frac{n}{2}\right)^{th}$ element&amp;quot;. Of course, this is correct. But what&amp;#39;s the runtime? hmmm... the lower bound of any comparison based sorting algorithm is a ceiling of $\log_2(n!)$ which is in order of $\Theta(n\log_2n)$. No matter what sorting algorithm do you use, the running time is $\Omega(n\log_2n)$. Can we do better? That is, can we find a median of an array in linear time?. The answer is yes. The following code calculates the median of an array in $O(n)$ time. The algorithm is called &amp;#39;Selection algorithm&amp;#39;. This algorithm calculates the &amp;#39;$k_{th}$&amp;#39; smallest value. Median is, therefore, $\left ( \frac{n}{2}\right)^{th}$&amp;#39; smallest element. The algorithm works as follows: (The code is also available on &lt;a href=&quot;https://github.com/Bibeknam/programming-techniques/blob/master/selection_algorithm.c&quot; target=&quot;_blank&quot;&gt;GitHub&lt;/a&gt;)&lt;br&gt;&lt;/div&gt;&lt;a href=&quot;https://www.programming-techniques.com/2017/10/selection-algorithm-implementation-in-c.html#more&quot;&gt;Read more »&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/3335180775250344639/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2017/10/selection-algorithm-implementation-in-c.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/3335180775250344639'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/3335180775250344639'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2017/10/selection-algorithm-implementation-in-c.html' title='Selection Algorithm (median of medians ) implementation in C'/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-1202561508856251413</id><published>2017-10-19T03:33:00.000+05:45</published><updated>2017-10-23T23:08:52.162+05:45</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Tutorial"/><title type='text'>Largest and Smallest Element of an Array in C</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Calculating largest and smallest element in C is straightforward. All you have to do is scan through the array one element at a time and compare it with current largest or smallest value. Since you scan every element of array, there will be n (number of elements in the array) comparisons. Therefore the running time of this algorithm is $\Theta(n)$.&lt;br /&gt;&lt;br /&gt;Calculation of Largest Element&lt;br /&gt;&lt;pre class=&quot;brush:c&quot;&gt;int get_largest(int a[], int n) {&lt;br /&gt; int i, largest = 0;&lt;br /&gt; for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;  if (a[i] &amp;gt; largest) {&lt;br /&gt;   largest = a[i];&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; return largest;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Calculation of Smallest Element&lt;br /&gt;&lt;pre class=&quot;brush:c&quot;&gt;int get_smallest(int a[], int n) {&lt;br /&gt; int i, smallest = 2147483647;&lt;br /&gt; for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;  if (a[i] &amp;lt; smallest) {&lt;br /&gt;   smallest = a[i];&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt; return smallest;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This code is also available in &lt;a href=&quot;https://github.com/Bibeknam/programming-techniques/blob/master/array_largest_smallest.c&quot; target=&quot;_blank&quot;&gt;GitHub&lt;/a&gt;.&amp;nbsp;&amp;nbsp;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/1202561508856251413/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2017/10/largest-and-smallest-element-of-array.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/1202561508856251413'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/1202561508856251413'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2017/10/largest-and-smallest-element-of-array.html' title='Largest and Smallest Element of an Array in C'/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-5195284737945507363</id><published>2017-10-19T02:06:00.002+05:45</published><updated>2017-10-23T23:08:59.163+05:45</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Tutorial"/><title type='text'>Pyramid and Star pattern generation in C</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Generating pyramid and other star patterns in C extend your knowledge of using a loop&amp;nbsp;in a program. In the program below I have generated various patterns. You can combine the multiple patterns to generate a&amp;nbsp;new pattern.&amp;nbsp; All patterns use for loop. The patterns that the code generates are:&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-3PCqEfXt0Rs/Wee2hknj2-I/AAAAAAAAB8M/pQqYk32rVkQZuSj-v_7Yu_2j9E2lkOxgwCLcBGAs/s1600/Screen%2BShot%2B2017-10-18%2Bat%2B1.15.45%2BPM.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;274&quot; data-original-width=&quot;156&quot; height=&quot;200&quot; src=&quot;https://4.bp.blogspot.com/-3PCqEfXt0Rs/Wee2hknj2-I/AAAAAAAAB8M/pQqYk32rVkQZuSj-v_7Yu_2j9E2lkOxgwCLcBGAs/s200/Screen%2BShot%2B2017-10-18%2Bat%2B1.15.45%2BPM.png&quot; width=&quot;113&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-yIfiLzYaEjU/Wee22_123yI/AAAAAAAAB8Q/EZwZEjTG0XIaZ7lEUkOZmWVsnYlCgiapQCLcBGAs/s1600/Screen%2BShot%2B2017-10-18%2Bat%2B1.16.10%2BPM.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;282&quot; data-original-width=&quot;152&quot; height=&quot;200&quot; src=&quot;https://2.bp.blogspot.com/-yIfiLzYaEjU/Wee22_123yI/AAAAAAAAB8Q/EZwZEjTG0XIaZ7lEUkOZmWVsnYlCgiapQCLcBGAs/s200/Screen%2BShot%2B2017-10-18%2Bat%2B1.16.10%2BPM.png&quot; width=&quot;107&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-U1WMqpbVUHs/Wee224BUO_I/AAAAAAAAB8Y/VRbfNHcTpeEDhCayzjGGO-PdMmNKBUFiQCLcBGAs/s1600/Screen%2BShot%2B2017-10-18%2Bat%2B1.16.17%2BPM.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;296&quot; data-original-width=&quot;278&quot; height=&quot;200&quot; src=&quot;https://4.bp.blogspot.com/-U1WMqpbVUHs/Wee224BUO_I/AAAAAAAAB8Y/VRbfNHcTpeEDhCayzjGGO-PdMmNKBUFiQCLcBGAs/s200/Screen%2BShot%2B2017-10-18%2Bat%2B1.16.17%2BPM.png&quot; width=&quot;187&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-k5hVnDZ5NHU/Wee228jxk6I/AAAAAAAAB8U/boQSmgkm-9gdkOUTxtSOTLB1gX1Ev1kRQCLcBGAs/s1600/Screen%2BShot%2B2017-10-18%2Bat%2B1.16.23%2BPM.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;270&quot; data-original-width=&quot;154&quot; height=&quot;200&quot; src=&quot;https://4.bp.blogspot.com/-k5hVnDZ5NHU/Wee228jxk6I/AAAAAAAAB8U/boQSmgkm-9gdkOUTxtSOTLB1gX1Ev1kRQCLcBGAs/s200/Screen%2BShot%2B2017-10-18%2Bat%2B1.16.23%2BPM.png&quot; width=&quot;114&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-sGMAqhG6u6g/Wee23BNkXfI/AAAAAAAAB8c/hbP-S0pTjgUJVD9Fu-0GY0ENDBXrGfITwCLcBGAs/s1600/Screen%2BShot%2B2017-10-18%2Bat%2B1.16.32%2BPM.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;286&quot; data-original-width=&quot;162&quot; height=&quot;200&quot; src=&quot;https://4.bp.blogspot.com/-sGMAqhG6u6g/Wee23BNkXfI/AAAAAAAAB8c/hbP-S0pTjgUJVD9Fu-0GY0ENDBXrGfITwCLcBGAs/s200/Screen%2BShot%2B2017-10-18%2Bat%2B1.16.32%2BPM.png&quot; width=&quot;113&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://1.bp.blogspot.com/-eZzFMybix_I/Wee23RC6OgI/AAAAAAAAB8g/gLXKclynRlgLfJrLwnFp3CDeQeBTGfh3gCLcBGAs/s1600/Screen%2BShot%2B2017-10-18%2Bat%2B1.16.49%2BPM.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;296&quot; data-original-width=&quot;280&quot; height=&quot;200&quot; src=&quot;https://1.bp.blogspot.com/-eZzFMybix_I/Wee23RC6OgI/AAAAAAAAB8g/gLXKclynRlgLfJrLwnFp3CDeQeBTGfh3gCLcBGAs/s200/Screen%2BShot%2B2017-10-18%2Bat%2B1.16.49%2BPM.png&quot; width=&quot;189&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://4.bp.blogspot.com/-Y3SOsRD2-Cg/Wee23fLJnII/AAAAAAAAB8k/y_4xmhsJTSMHSfYs0zzRJTEPMvprQ51zQCLcBGAs/s1600/Screen%2BShot%2B2017-10-18%2Bat%2B1.16.56%2BPM.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;560&quot; data-original-width=&quot;290&quot; height=&quot;320&quot; src=&quot;https://4.bp.blogspot.com/-Y3SOsRD2-Cg/Wee23fLJnII/AAAAAAAAB8k/y_4xmhsJTSMHSfYs0zzRJTEPMvprQ51zQCLcBGAs/s320/Screen%2BShot%2B2017-10-18%2Bat%2B1.16.56%2BPM.png&quot; width=&quot;164&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-riiDgDaU_mU/Wee23vPy-4I/AAAAAAAAB8o/_CARBhSI8hgZgZzn1PefwvUpuPpT4LGnQCLcBGAs/s1600/Screen%2BShot%2B2017-10-18%2Bat%2B1.17.06%2BPM.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;554&quot; data-original-width=&quot;298&quot; height=&quot;320&quot; src=&quot;https://2.bp.blogspot.com/-riiDgDaU_mU/Wee23vPy-4I/AAAAAAAAB8o/_CARBhSI8hgZgZzn1PefwvUpuPpT4LGnQCLcBGAs/s320/Screen%2BShot%2B2017-10-18%2Bat%2B1.17.06%2BPM.png&quot; width=&quot;171&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The sample code is also available on &lt;a href=&quot;https://github.com/Bibeknam/programming-techniques/blob/master/starpatterns.c&quot; target=&quot;_blank&quot;&gt;Github&lt;/a&gt;&lt;br /&gt;&lt;pre class=&quot;brush:c&quot;&gt;#include &lt;stdio .h=&quot;&quot;&gt;&lt;br /&gt;#include &lt;stdlib .h=&quot;&quot;&gt;&lt;br /&gt;&lt;br /&gt;void pattern_1(int n) {&lt;br /&gt; int i, j;&lt;br /&gt;&lt;br /&gt; for(i = 0; i &amp;lt; n; i++) {&lt;br /&gt;  for (j = 0; j &amp;lt;= i; j++) {&lt;br /&gt;   printf(&quot;*&quot;);&lt;br /&gt;  }&lt;br /&gt;  printf(&quot;\n&quot;);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void pattern_2(int n) {&lt;br /&gt; int i, j;&lt;br /&gt;&lt;br /&gt; for(i = 0; i &amp;lt; n; i++) {&lt;br /&gt;  for(j = 0; j &amp;lt; n - i - 1; j++) {&lt;br /&gt;   printf(&quot; &quot;);&lt;br /&gt;  }&lt;br /&gt;  for (j = 0; j &amp;lt;= i; j++) {&lt;br /&gt;   printf(&quot;*&quot;);&lt;br /&gt;  }&lt;br /&gt;  printf(&quot;\n&quot;);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void pattern_3(int n) {&lt;br /&gt; int i, j;&lt;br /&gt;&lt;br /&gt; for(i = 0; i &amp;lt; n; i++) {&lt;br /&gt;  for(j = 0; j &amp;lt; n - i - 1; j++) {&lt;br /&gt;   printf(&quot; &quot;);&lt;br /&gt;  }&lt;br /&gt;  for (j = 0; j &amp;lt;= 2 * i; j++) {&lt;br /&gt;   printf(&quot;*&quot;);&lt;br /&gt;  }&lt;br /&gt;  printf(&quot;\n&quot;);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void pattern_4(int n) {&lt;br /&gt; int i, j;&lt;br /&gt; for(i = n - 1; i &amp;gt;= 0; i--) {&lt;br /&gt;  for (j = 0; j &amp;lt;= i; j++) {&lt;br /&gt;   printf(&quot;*&quot;);&lt;br /&gt;  }&lt;br /&gt;  printf(&quot;\n&quot;);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void pattern_5(int n) {&lt;br /&gt; int i, j;&lt;br /&gt; for(i = n - 1; i &amp;gt;= 0; i--) {&lt;br /&gt;  for(j = 0; j &amp;lt; n - i - 1; j++) {&lt;br /&gt;   printf(&quot; &quot;);&lt;br /&gt;  }&lt;br /&gt;  for (j = 0; j &amp;lt;= i; j++) {&lt;br /&gt;   printf(&quot;*&quot;);&lt;br /&gt;  }&lt;br /&gt;  printf(&quot;\n&quot;);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void pattern_6(int n) {&lt;br /&gt; int i, j;&lt;br /&gt;&lt;br /&gt; for(i = n - 1; i &amp;gt;= 0; i--) {&lt;br /&gt;  for(j = 0; j &amp;lt; n - i - 1; j++) {&lt;br /&gt;   printf(&quot; &quot;);&lt;br /&gt;  }&lt;br /&gt;  for (j = 0; j &amp;lt;= 2 * i; j++) {&lt;br /&gt;   printf(&quot;*&quot;);&lt;br /&gt;  }&lt;br /&gt;  printf(&quot;\n&quot;);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void pattern_7(int n) {&lt;br /&gt; int i, j;&lt;br /&gt;&lt;br /&gt; for(i = 0; i &amp;lt; n; i++) {&lt;br /&gt;  for(j = 0; j &amp;lt; n - i; j++) {&lt;br /&gt;   printf(&quot; &quot;);&lt;br /&gt;  }&lt;br /&gt;  for (j = 0; j &amp;lt;= 2 * i; j++) {&lt;br /&gt;   printf(&quot;*&quot;);&lt;br /&gt;  }&lt;br /&gt;  printf(&quot;\n&quot;);&lt;br /&gt; }&lt;br /&gt; for(i = (n - 1) ; i &amp;gt;= 0; i--) {&lt;br /&gt;  for(j = 0; j &amp;lt; n - i; j++) {&lt;br /&gt;   printf(&quot; &quot;);&lt;br /&gt;  }&lt;br /&gt;  for (j = 0; j &amp;lt;= 2 * i; j++) {&lt;br /&gt;   printf(&quot;*&quot;);&lt;br /&gt;  }&lt;br /&gt;  printf(&quot;\n&quot;);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void pattern_8(int n) {&lt;br /&gt; int i, j, k;&lt;br /&gt; for (i = 0; i &amp;lt; n; i++) {&lt;br /&gt;  printf(&quot;\n&quot;);&lt;br /&gt;  for(k = 0; k &amp;lt; n - i; k++) {&lt;br /&gt;   printf(&quot;*&quot;);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  for(k = 2*i; k &amp;gt; 0; k--) {&lt;br /&gt;   printf(&quot; &quot;);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  for(k = 0; k &amp;lt; n - i; k++) {&lt;br /&gt;   printf(&quot;*&quot;);&lt;br /&gt;  }&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt; }&lt;br /&gt; for (i = 0; i &amp;lt;= n; i++) {&lt;br /&gt;  for(k = 0; k &amp;lt; i; k++) {&lt;br /&gt;   printf(&quot;*&quot;);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  for(k = 0; k &amp;lt; 2* (n - i); k++) {&lt;br /&gt;   printf(&quot; &quot;);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  for(k = 0; k &amp;lt; i; k++) {&lt;br /&gt;   printf(&quot;*&quot;);&lt;br /&gt;  }&lt;br /&gt;  printf(&quot;\n&quot;);&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main(int argc, char *argv[]) {&lt;br /&gt; int n;&lt;br /&gt; if (argc != 2) {&lt;br /&gt;  printf(&quot;Usage: outputfile n\n&quot;);&lt;br /&gt;  exit(1);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; n = atoi(argv[1]);&lt;br /&gt;&lt;br /&gt; pattern_1(n);&lt;br /&gt; printf(&quot;\n&quot;);&lt;br /&gt; pattern_2(n);&lt;br /&gt; printf(&quot;\n&quot;);&lt;br /&gt; pattern_3(n);&lt;br /&gt; printf(&quot;\n&quot;);&lt;br /&gt; pattern_4(n);&lt;br /&gt; printf(&quot;\n&quot;);&lt;br /&gt; pattern_5(n);&lt;br /&gt; printf(&quot;\n&quot;);&lt;br /&gt; pattern_6(n);&lt;br /&gt; printf(&quot;\n&quot;);&lt;br /&gt; pattern_7(n);&lt;br /&gt; printf(&quot;\n&quot;);&lt;br /&gt; pattern_8(n);&lt;br /&gt;}&lt;br /&gt;&lt;/stdlib&gt;&lt;/stdio&gt;&lt;/pre&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/5195284737945507363/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2017/10/pyramid-and-start-pattern-generation-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/5195284737945507363'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/5195284737945507363'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2017/10/pyramid-and-start-pattern-generation-in.html' title='Pyramid and Star pattern generation in C'/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://4.bp.blogspot.com/-3PCqEfXt0Rs/Wee2hknj2-I/AAAAAAAAB8M/pQqYk32rVkQZuSj-v_7Yu_2j9E2lkOxgwCLcBGAs/s72-c/Screen%2BShot%2B2017-10-18%2Bat%2B1.15.45%2BPM.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-1994002374105036455</id><published>2016-03-06T13:09:00.002+05:45</published><updated>2016-03-06T13:16:46.998+05:45</updated><category scheme="http://www.blogger.com/atom/ns#" term="Javascript Tutorial"/><title type='text'>Difference between exports and module.exports in Node.js</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;When you have large javascript file, you want to break that file into independent modules so that you can reuse each module in different files.  Node.js follows CommonJS module system in which modules are imported using &lt;code&gt;require&lt;/code&gt; method available in global scope. For example, lets say you have two files, &lt;code&gt;person.js&lt;/code&gt; and &lt;code&gt;main.js&lt;/code&gt;. To import &lt;code&gt;person.js&lt;/code&gt; functionality into &lt;code&gt;main.js&lt;/code&gt;, you would do this&lt;br&gt;&lt;br&gt;&lt;code&gt;var Person = require(&amp;#39;person&amp;#39;);&lt;/code&gt;&lt;br&gt;&lt;br&gt;Now you can use methods defined in person.js in main.js using Person variable. To be able to get the Person variable from person.js file, we should have return statement inside the &lt;code&gt;person.js&lt;/code&gt; file so that &lt;code&gt;require&lt;/code&gt; method assigns return value to the Person variable.  person.js would look like this&lt;br&gt;&lt;/div&gt;&lt;a href=&quot;https://www.programming-techniques.com/2016/03/difference-between-exports-and.html#more&quot;&gt;Read more »&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/1994002374105036455/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2016/03/difference-between-exports-and.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/1994002374105036455'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/1994002374105036455'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2016/03/difference-between-exports-and.html' title='Difference between exports and module.exports in Node.js'/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-2104332149005539989</id><published>2016-03-05T10:00:00.001+05:45</published><updated>2016-03-05T10:03:20.243+05:45</updated><title type='text'>Sorting Java objects based on property </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;In Java, sorting of group of &amp;nbsp;primitive type is simple. That is, sorting of group of integers, floats, doubles or strings is one step process (if you don&#39;t use your own algorithm for sorting). &amp;nbsp;java.util provides various methods for sorting these kind of group. Two of them are :&lt;br /&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Arrays.sort()&lt;/li&gt;&lt;li&gt;Collections.sort()&lt;/li&gt;&lt;/ol&gt;Why sorting of group of primitive type is simple?&lt;br /&gt;&lt;br /&gt;The answer is Java knows what exactly are those types and how to compare those types to each other. For example, comparing two integers is simply using the logical &amp;lt;, = and &amp;gt; operator. Similar for float, double and strings.&lt;br /&gt;&lt;br /&gt;But, if you have your custom type (i.e. class) of data, then Java doesn&#39;t know what to do with them. &amp;nbsp;Lets say you have group of people with different properties like height, weight, age, name, religion and so on, &amp;nbsp;and you want Java to sort these people in increasing order. When Java tries to compare two people, it gets confused. It doesn&#39;t know which parameter to consider for sorting. Sorting can be done based on height, weight, age etc but which one to take as a parameter to decide?&lt;br /&gt;&lt;br /&gt;To solve this problem, you need to explicitly specify the property. Based on the property, comparison should be carried out i.e. if you want to sort people based on their height, you need to tell Java explicitly that I want to sort people based on their height.&lt;br /&gt;&lt;br /&gt;Programatically, this can be accomplished using Comparator interface as follows.&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;brush:java&quot;&gt;Collections.sort(persons, new Comparator () {&lt;br /&gt;        @Override&lt;br /&gt; public int compare(Person p1, Person p2) {&lt;br /&gt;  return Integer.compare(p1.height, p2.height);&lt;br /&gt; }&lt;br /&gt;});&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Passing implementation of Comparator interface as a second argument to Collection.sort method helps Java to make decision while comparing between two objects.&lt;br /&gt;&lt;br /&gt;In above code snippet, you see that you need to implement one method i.e. compare , to carry out this operation. &amp;nbsp;If you closely observe the code you can see we &amp;nbsp;have explicitly specified that sorting needs to be carried out based on height. The compare method returns 3 possible values&lt;br /&gt;&lt;br /&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;A negative integer -&amp;gt; means first argument is less than second argument&lt;/li&gt;&lt;li&gt;Zero -&amp;gt; means both arguments are equal&lt;/li&gt;&lt;li&gt;A positive integer -&amp;gt; means first argument is greater than second argument&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;A runnable example for sorting is given bellow.&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;brush:java&quot;&gt;import java.util.*;&lt;br /&gt;class Person {&lt;br /&gt; // height in cm&lt;br /&gt; public int height; &lt;br /&gt; public String name;&lt;br /&gt; public Person(int height, String name) {&lt;br /&gt;  this.height = height;&lt;br /&gt;  this.name = name;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;class CustomSort {&lt;br /&gt; static void sort(List persons) {&lt;br /&gt;  Collections.sort(persons, new Comparator () {&lt;br /&gt;   @Override&lt;br /&gt;   public int compare(Person p1, Person p2) {&lt;br /&gt;    return Integer.compare(p1.height, p2.height);&lt;br /&gt;   }&lt;br /&gt;  });&lt;br /&gt; }&lt;br /&gt; public static void main(String [] args) {&lt;br /&gt;  List persons = new ArrayList&amp;lt;&amp;gt;();&lt;br /&gt;  // add some persons to arraylist&lt;br /&gt;  persons.add(new Person(154, &quot;John&quot;));&lt;br /&gt;  persons.add(new Person(150, &quot;Henry&quot;));&lt;br /&gt;  persons.add(new Person(160, &quot;Smith&quot;));&lt;br /&gt;  persons.add(new Person(162, &quot;Bob&quot;));&lt;br /&gt;  persons.add(new Person(155, &quot;Rubina&quot;));&lt;br /&gt;  persons.add(new Person(170, &quot;Stiva&quot;));&lt;br /&gt;  persons.add(new Person(178, &quot;Bijay&quot;));&lt;br /&gt;  CustomSort.sort(persons);&lt;br /&gt;  System.out.println(&quot;Sorted persons based on height&quot;);&lt;br /&gt;  System.out.println();&lt;br /&gt;  for (Person person: persons) {&lt;br /&gt;   System.out.println(person.name);&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/2104332149005539989/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2016/03/sorting-java-objects-based-on-property.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/2104332149005539989'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/2104332149005539989'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2016/03/sorting-java-objects-based-on-property.html' title='Sorting Java objects based on property '/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-1773569810540752091</id><published>2015-09-30T20:23:00.001+05:45</published><updated>2015-10-01T09:48:07.499+05:45</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android Application Development"/><title type='text'>Retrofit 2.0 tutorial with sample application</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Retrofit is a HTTP client library in Android and Java. It has great performance compares to AsyncTask and other android networking libraries. Retrofit 2.0 has been released few months back with major update. In this tutorial I am going to talk about how to create a simple REST client  in Android that communicates with REST endpoint to perform the READ and WRITE operations. This tutorial is intended for retrofit 2.0 beginner who are using retrofit for first time and getting their hand dirty with retrofit 2.0.&lt;br&gt;&lt;br&gt;The overview of application that we are creating is as follows. The application has two main components 1) REST client in Android 2) REST server in Node.js. We will focus on REST client as this writing is for retrofit which is client library. We will create REST endpoints that creates and list User. User has two properties., username and name. The program  (Client) has two methods; one for creating user and other for listing all the users. Final android application has two fragments in pager view, one has interface for creating new user and another for listing the user. In backend, the program uses Mongodb as database. &lt;br&gt;&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;a href=&quot;https://www.programming-techniques.com/2015/09/retrofit-20-tutorial-with-sample.html#more&quot;&gt;Read more »&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/1773569810540752091/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2015/09/retrofit-20-tutorial-with-sample.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/1773569810540752091'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/1773569810540752091'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2015/09/retrofit-20-tutorial-with-sample.html' title='Retrofit 2.0 tutorial with sample application'/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-2474542440739066551</id><published>2014-02-07T15:35:00.000+05:45</published><updated>2014-02-24T14:17:19.394+05:45</updated><category scheme="http://www.blogger.com/atom/ns#" term="Image Processing"/><title type='text'>Discrete Cosine Transform and JPEG compression : Image Processing</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;JPEG is well known standard for image compression and Discrete Cosine Transform (DCT) is the mathematical tool used by JPEG for achieving the compression. JPEG is lossy compression meaning some information is lost during the compression. Lets dig deeper into the JPEG standard starting from the block diagram.&lt;br&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-ZsvLtk5apH4/UvMauiwBvDI/AAAAAAAAAv8/x0yqG0I9te8/s1600/encoder.gif&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://2.bp.blogspot.com/-ZsvLtk5apH4/UvMauiwBvDI/AAAAAAAAAv8/x0yqG0I9te8/s1600/encoder.gif&quot; height=&quot;251&quot; width=&quot;400&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;br&gt;&lt;div&gt;Above diagram shows the encoder part of JPEG. The decoder is the reverse of encoder except it doesn&amp;#39;t contains the reverse part of Quantizer block and this is the main reason why JPEG is lossy compression. We cannot recover data lost during the quantization step. The operations performed by each block is presented below&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;a href=&quot;https://www.programming-techniques.com/2014/02/discrete-cosine-transform-and-jpeg.html#more&quot;&gt;Read more »&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/2474542440739066551/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2014/02/discrete-cosine-transform-and-jpeg.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/2474542440739066551'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/2474542440739066551'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2014/02/discrete-cosine-transform-and-jpeg.html' title='Discrete Cosine Transform and JPEG compression : Image Processing'/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-ZsvLtk5apH4/UvMauiwBvDI/AAAAAAAAAv8/x0yqG0I9te8/s72-c/encoder.gif" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-250400963218986695</id><published>2014-01-09T15:28:00.000+05:45</published><updated>2017-11-21T01:30:06.815+05:45</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android Application Development"/><title type='text'>Google Cloud Messaging (GCM) in Android using PHP Server</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;GCM for Android is a service which is basically used to send the data from the server to the android devices. One use of this GCM is a push notification service. In this tutorial, I am going through all the steps needed to setup the GCM and build a simple but complete android application in Eclipse.&lt;br&gt;&lt;/div&gt;&lt;a href=&quot;https://www.programming-techniques.com/2014/01/google-cloud-messaging-gcm-in-android.html#more&quot;&gt;Read more »&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/250400963218986695/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2014/01/google-cloud-messaging-gcm-in-android.html#comment-form' title='56 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/250400963218986695'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/250400963218986695'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2014/01/google-cloud-messaging-gcm-in-android.html' title='Google Cloud Messaging (GCM) in Android using PHP Server'/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://1.bp.blogspot.com/-SaSzyAccgpY/Us4tNHPiAJI/AAAAAAAAAu0/MCLa4VnxSBU/s72-c/GCM+architecture.PNG" height="72" width="72"/><thr:total>56</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-3437921744088874307</id><published>2013-12-26T12:56:00.000+05:45</published><updated>2013-12-26T20:37:35.065+05:45</updated><category scheme="http://www.blogger.com/atom/ns#" term="Machine Learning"/><title type='text'>Logistic Regression in Machine Learning</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Before studying logistic regression, I would recommend you to go through these tutorials.&lt;br&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;a href=&quot;http://www.programming-techniques.com/2013/11/linear-regression-on-machine-learning.html&quot; target=&quot;_blank&quot;&gt;Linear Regression in Machine Learning&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.programming-techniques.com/2013/12/gradient-descent-versus-normal-equation.html&quot; target=&quot;_blank&quot;&gt;Gradient descent vs normal equation&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;The first and most important thing about logistic regression is that it is not a &amp;quot;Regression&amp;quot; but a &amp;quot;Classification&amp;quot; algorithm. The name itself is somewhat misleading. Regression gives a continuous numeric output but most of the time we need the output in classes (i.e. categorical, discrete). For example, we want to classify emails into &amp;quot;spam&amp;quot; or &amp;quot;not spam&amp;quot;,  classify treatment into &amp;quot;success&amp;quot; or &amp;quot;failure&amp;quot;, classify statement into &amp;quot;right&amp;quot; or &amp;quot;wrong&amp;quot; , classify transactions into &amp;quot;fraudulent&amp;quot; or &amp;quot;non-fraudulent&amp;quot; and so on. These are the examples of  logistic regression having binary output (also called dichotomous). Note that the output may not always be binary but in this article I merely talk about  binary output.&lt;br&gt;&lt;/div&gt;&lt;a href=&quot;https://www.programming-techniques.com/2013/12/logistic-regression-in-machine-learning.html#more&quot;&gt;Read more »&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/3437921744088874307/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2013/12/logistic-regression-in-machine-learning.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/3437921744088874307'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/3437921744088874307'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2013/12/logistic-regression-in-machine-learning.html' title='Logistic Regression in Machine Learning'/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-FMlVYQecYZI/Urp_4i2RJ2I/AAAAAAAAAuU/lNgGQ12nkVc/s72-c/logisticRegression.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-2832016166759052933</id><published>2013-12-21T23:34:00.001+05:45</published><updated>2013-12-23T10:47:27.272+05:45</updated><category scheme="http://www.blogger.com/atom/ns#" term="Data Analysis"/><category scheme="http://www.blogger.com/atom/ns#" term="R"/><title type='text'>Nepal over last Four Decades with R</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div&gt;The &lt;a href=&quot;http://databank.worldbank.org/data/views/variableselection/selectvariables.aspx?source=world-development-indicators&quot; target=&quot;_blank&quot;&gt;World Bank DataBank&lt;/a&gt; provides the data of all countries for more than 1000 indicators since 1960. It can be used for various statistical analysis purpose. This weekend, I downloaded the Data for Nepal, and tried few simple things in R, mainly for the purpose of learning R. R is very powerful statistical analysis tool.&lt;br&gt;&lt;br&gt;The data was downloaded as csv file, which can be read with read.csv() function in R. We can run the R commands from R command line, and its really interactive.&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;a href=&quot;https://www.programming-techniques.com/2013/12/visualizing-nepals-progress-over-last.html#more&quot;&gt;Read more »&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/2832016166759052933/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2013/12/visualizing-nepals-progress-over-last.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/2832016166759052933'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/2832016166759052933'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2013/12/visualizing-nepals-progress-over-last.html' title='Nepal over last Four Decades with R'/><author><name>Umanga Bista</name><uri>http://www.blogger.com/profile/04111588924121271705</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-t-_CcWJVmyk/UrW0vlPFpAI/AAAAAAAABB4/9jOxbIPoVCA/s72-c/NRS+Vs+USD+Trend.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-4607836997693481014</id><published>2013-12-21T14:23:00.001+05:45</published><updated>2013-12-24T15:21:31.409+05:45</updated><category scheme="http://www.blogger.com/atom/ns#" term="Machine Learning"/><title type='text'>Gradient descent versus normal equation </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Gradient descent and normal equation (also called batch processing) both are methods for finding out the local minimum of a function. I have given some intuition about gradient descent in &lt;a href=&quot;http://www.programming-techniques.com/2013/11/linear-regression-on-machine-learning.html&quot; target=&quot;_blank&quot;&gt;previous article&lt;/a&gt;. Gradient descent is actually an iterative method to find out the parameters. We start with the initial guess of the parameters (usually zeros but not necessarily), and gradually adjust those parameters so that we get the function that best fit the given data points. Here is the mathematical formulation of gradient descent in the case of linear regression.&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;a href=&quot;https://www.programming-techniques.com/2013/12/gradient-descent-versus-normal-equation.html#more&quot;&gt;Read more »&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/4607836997693481014/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2013/12/gradient-descent-versus-normal-equation.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/4607836997693481014'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/4607836997693481014'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2013/12/gradient-descent-versus-normal-equation.html' title='Gradient descent versus normal equation '/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-1229139298260514180</id><published>2013-12-10T11:01:00.000+05:45</published><updated>2013-12-10T11:01:35.780+05:45</updated><category scheme="http://www.blogger.com/atom/ns#" term="Numerical Methods"/><title type='text'>Numerical Methods Tutorials </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;This section consists of various numerical methods problems and their solution in C language. You can click each link to view the source code of corresponding problem in C.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;a href=&quot;http://www.programming-techniques.com/2011/09/numerical-method-solution-of-ordinary.html&quot;&gt;Solution of Differential Equation using RK4 method&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.programming-techniques.com/2011/09/numerical-methods-solution-of-non.html&quot;&gt;Solution of Non-linear equation by Bisection Method&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.programming-techniques.com/2011/09/numerical-methods-solution-of-non_18.html&quot;&gt;Solution of Non-linear equation by Newton Raphson Method&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.programming-techniques.com/2011/09/numerical-methods-solution-of-non_6370.html&quot;&gt;Solution of Non-linear equation by Secant Method&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.programming-techniques.com/2011/09/numerical-methods-interpolation-with.html&quot;&gt;Interpolation with unequal method by Lagrange&#39;s Method&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.programming-techniques.com/2011/09/numerical-methodsfitting-curve-of-form.html&quot;&gt;Linear Curve Fitting&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.programming-techniques.com/2011/09/numerical-methods-parabolic-curve.html&quot;&gt;Parabolic Curve Fitting&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.programming-techniques.com/2011/09/numerical-methods-solution-of_18.html&quot;&gt;Gauss Jordan Method&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.programming-techniques.com/2011/09/numerical-methods-determinant-of-nxn.html&quot;&gt;Determinant of a NxN Matrix&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.programming-techniques.com/2011/09/numerical-methods-inverse-of-nxn-matrix.html&quot;&gt;Inverse of a NxN Matrix&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.programming-techniques.com/2011/09/numerical-methods-integration-of-given.html&quot;&gt;Integration using Trapezoidal Rule&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.programming-techniques.com/2011/09/numerical-methods-integration-of-given_18.html&quot;&gt;Integration using Simpson&#39;s 3/8 Rule&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.programming-techniques.com/2011/09/numerical-methods-integration-of-given_6759.html&quot;&gt;Integration using Simpson&#39;s 1/3 Rule&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.programming-techniques.com/2011/09/numerical-methods-greatest-eigen-value.html&quot;&gt;Greatest Eigen value and Eigen vector using Power Method&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.programming-techniques.com/2011/09/numerical-methods-condition-number-and.html&quot;&gt;Condition number and ill condition checking&amp;nbsp;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.programming-techniques.com/2012/01/numerical-method-newtons-forward-and.html&quot;&gt;Newton&#39;s Forward and Backward interpolation&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://www.programming-techniques.com/2012/03/numerical-methods-multiplication-of-two.html&quot;&gt;2 Dimensional matrix multiplication&amp;nbsp;&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;b&gt;Note&lt;/b&gt;: All the codes are compiled in GCC Mingw compiler in windows. Attempting to compile in other compiler and platform may result errors. These tutorials are targeted for student and for learning purpose, so the code may not be optimized for the actual implementation. Some operations like matrix inversion and determinant are done without pivoting, divide by zero error may result in some cases. Partial and full pivoting are recommended.&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/1229139298260514180/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2013/12/numerical-methods-tutorials.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/1229139298260514180'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/1229139298260514180'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2013/12/numerical-methods-tutorials.html' title='Numerical Methods Tutorials '/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-5493553756420542502</id><published>2013-11-01T10:41:00.002+05:45</published><updated>2013-12-30T14:25:39.200+05:45</updated><category scheme="http://www.blogger.com/atom/ns#" term="Business Intelligence"/><title type='text'>Business Intelligence (BI) implementation in Nepalese Telecommunications</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;This article aims at discovering the business intelligence technologies that can be applied to the telecommunication industries to facilitate the business process. I have used the data warehouse approach to build the warehouse of telecom data from which various reporting tolls can be used to visualize these data and perform various types of analysis to support the decision making process. Furthermore, I have pointed out some data mining methods that can be added to make it more intelligent as its name &quot;Business Intelligence&#39;. This article shows all the steps from data collection to report generation through warehouse ETC process with related technological background and tools and technologies wherever necessary.&lt;br /&gt;&lt;br /&gt;You can download the full article from &lt;a href=&quot;https://dl.dropboxusercontent.com/s/m62lcxho5u9ully/BI%20in%20Telecom.pdf?dl=1&amp;amp;token_hash=AAGug_vGAAPH1Jmu4FHQbC6-wboO7_92h2HkC3a8T2dWxw&quot;&gt;here&lt;/a&gt;.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/5493553756420542502/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2013/11/business-intelligence-bi-implementation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/5493553756420542502'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/5493553756420542502'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2013/11/business-intelligence-bi-implementation.html' title='Business Intelligence (BI) implementation in Nepalese Telecommunications'/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-4573630926686306571</id><published>2013-11-01T09:15:00.000+05:45</published><updated>2013-12-24T17:12:37.813+05:45</updated><category scheme="http://www.blogger.com/atom/ns#" term="Machine Learning"/><title type='text'>Linear Regression in Machine Learning</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Linear regression is used in machine learning to predict the output for a new data based on the previous data set. Suppose you have data set of shoes containing 100 different sized shoes along with prices. Now if you want to predict a price of a shoe of size (say) 9.5 then one way of doing prediction is by using linear regression. We train the model based on those 100 data. After training we will have a hypothesis and based on this hypothesis we can predict the price of the new shoe.&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;a href=&quot;https://www.programming-techniques.com/2013/11/linear-regression-on-machine-learning.html#more&quot;&gt;Read more »&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/4573630926686306571/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2013/11/linear-regression-on-machine-learning.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/4573630926686306571'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/4573630926686306571'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2013/11/linear-regression-on-machine-learning.html' title='Linear Regression in Machine Learning'/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-ZFER24Vv838/Urlm2sibWzI/AAAAAAAAAuE/qRUkd6RTl_Q/s72-c/linearRegressionModel.PNG" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-389728763001017335</id><published>2013-07-22T15:04:00.002+05:45</published><updated>2017-11-09T00:37:29.626+05:45</updated><category scheme="http://www.blogger.com/atom/ns#" term="Javascript Tutorial"/><category scheme="http://www.blogger.com/atom/ns#" term="PHP Tutorial"/><title type='text'>Fetch Data from MYSQL using Jquery Ajax</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;This is really an interesting article where I will show you how to fetch data from MySQL table using Jquery Ajax. If you are familiar with PHP, then you may already know about how to fetch data using PHP. But in this tutorial, I will show a completely different way of doing this. Ajax is a technology which extracts and displays the web content without loading the full page. I can update a single HTML &amp;lt;div&amp;gt; without loading the full website. Now, lets move to a step by step procedures for pulling all the data out of MySQL table and displaying in HTML table.&lt;br&gt;&lt;br&gt;&lt;/div&gt;The first thing you need to do is create a simple MySQL database with some tables with some data. You can do this using simple SQL query but I have already a data of &lt;a href=&quot;https://dl-web.dropbox.com/get/population.sql?w=AABBEReYP_azdZ4swpDpPFvPRShHFXErjIhGoIMO8qbELA&amp;amp;dl=1&quot; style=&quot;border: 0px; color: #21759b; margin: 0px; outline: none; padding: 0px; vertical-align: baseline;&quot;&gt;population of districts of Nepal&lt;/a&gt; in my database. I will use it in this tutorial. If you want to display different data then its ok just create a mysql table and insert some data in it.&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;a href=&quot;https://www.programming-techniques.com/2013/07/fetch-data-from-mysql-using-jquery-ajax.html#more&quot;&gt;Read more »&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/389728763001017335/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2013/07/fetch-data-from-mysql-using-jquery-ajax.html#comment-form' title='16 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/389728763001017335'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/389728763001017335'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2013/07/fetch-data-from-mysql-using-jquery-ajax.html' title='Fetch Data from MYSQL using Jquery Ajax'/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://2.bp.blogspot.com/-6UneJfXQ8DE/Uez3x8SasqI/AAAAAAAAAo4/zqoA8EfhYTM/s72-c/district.png" height="72" width="72"/><thr:total>16</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-9074628258854401669</id><published>2013-07-18T09:03:00.001+05:45</published><updated>2017-11-09T00:52:07.698+05:45</updated><category scheme="http://www.blogger.com/atom/ns#" term="Artificial Intelligence"/><title type='text'>Solving Knapsack problem using Dynamic Programming</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;This is post is basically for solving the Knapsack problem, very famous problem in optimization community, using dynamic programming. But remember this problem can be solved using various approaches with different complexities, but here I shall talk about only dynamic programming, specifically bottom-up approach. So lets first talk about what is Knapsack problem for the people who are unfamiliar with it. The Knapsack problem states that “Given a set of items, each with a weight and a value, determine the number of each item include in a collection so that the total weight is less than or equal to a given limit and the total value is as large as possible”. Let&amp;#39;s consider a concrete example, suppose you have a Knapsack and you have lots of books and articles. You are planning to go somewhere in your vacation and you want to keep some important books and articles with you. The Knapsack has fix capacity so you cannot keep all the books and articles that you got inside the knapsack.&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;a href=&quot;https://www.programming-techniques.com/2013/07/solving-knapsack-problem-using-dynamic.html#more&quot;&gt;Read more »&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/9074628258854401669/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2013/07/solving-knapsack-problem-using-dynamic.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/9074628258854401669'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/9074628258854401669'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2013/07/solving-knapsack-problem-using-dynamic.html' title='Solving Knapsack problem using Dynamic Programming'/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://2.bp.blogspot.com/-3eZd023dUtw/Uedb-5haCGI/AAAAAAAAAng/SlP1U27KtFA/s72-c/table.jpg" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-7787001421264557266</id><published>2013-06-22T17:56:00.001+05:45</published><updated>2017-10-25T23:06:05.177+05:45</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Projects"/><title type='text'>C Mini Project Ideas with a Sample Calculator Project</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Do you want to build a simple application in C but you don’t know how and where to start? Or you know how to build a C application but don’t know any project ideas? then do not worry you are at the right place. If you finished learning  C and became familiar with its programming paradigm then I encourage you to build some applications (whether it is application software or system software) to actually sharpen your skills in C. If you do projects, then you will know how to apply those programming constructs accurately in building projects. So here I will explain how to start a new C project for complete beginner and give some projects ideas about what type of application you can build using C language&lt;br&gt;I have some suggestions for people who are about to write their first C application.&lt;br&gt;&lt;/div&gt;&lt;a href=&quot;https://www.programming-techniques.com/2013/06/c-mini-project-ideas-with-sample.html#more&quot;&gt;Read more »&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/7787001421264557266/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2013/06/c-mini-project-ideas-with-sample.html#comment-form' title='13 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/7787001421264557266'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/7787001421264557266'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2013/06/c-mini-project-ideas-with-sample.html' title='C Mini Project Ideas with a Sample Calculator Project'/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><thr:total>13</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-4749181842870767409</id><published>2013-05-17T15:47:00.001+05:45</published><updated>2013-05-17T15:51:27.730+05:45</updated><category scheme="http://www.blogger.com/atom/ns#" term="Cplusplus Tutorial"/><title type='text'>Basic Euclidean vector operations in C++</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Euclidean vectors are very important quantity in mathematics, applied mathematics, physics, engineering etc. Formally vectors are those quantity which have both magnitude and direction. For example velocity. Velocity has both magnitude (Speed, like 2 Km/Hr) and direction (e.g. east). In programmer’s perspective, there are many situation where you need to compute different vector operations. For example consider a moving ball. To simulate the motion of ball, you must calculate the velocity of the ball. The ball has both magnitude (i.e rate of translation of  position of center of the ball) and direction (e.g. axis x or y or z). This is just one example but there are various examples where vector operations are essential. &lt;br&gt;Now in this article, I will show you how to compute different vector operations like, sum of two vectors, multiplication by scalar, dot product, cross product, normalization etc in C++. I choose C++ instead of C because it is &lt;a href=&quot;http://programming-technique.blogspot.com/2011/10/c-tutorial-objects-and-classes-in-c.html&quot;&gt;object oriented&lt;/a&gt;. The vector can be represented by an &lt;a href=&quot;http://programming-technique.blogspot.com/2011/10/c-tutorial-objects-and-classes-in-c.html&quot;&gt;object&lt;/a&gt;. The components of vector along x, y and z axis will be the data member of the object. The data members are attributes of the object. Similarly different operations will be the member functions of the object. Now the vector object can completely represent the vector quantity.&lt;br&gt;&lt;/div&gt;&lt;a href=&quot;https://www.programming-techniques.com/2013/05/basic-euclidean-vector-operations-in-c.html#more&quot;&gt;Read more »&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/4749181842870767409/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2013/05/basic-euclidean-vector-operations-in-c.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/4749181842870767409'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/4749181842870767409'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2013/05/basic-euclidean-vector-operations-in-c.html' title='Basic Euclidean vector operations in C++'/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-fkTRhpBKWEw/UZYAGlMOAtI/AAAAAAAAAms/tGS7Np34NHI/s72-c/vectorOp_thumb2.jpg?imgmax=800" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8220923316510870669.post-611915916033260383</id><published>2013-05-14T02:08:00.001+05:45</published><updated>2017-11-06T01:38:18.948+05:45</updated><category scheme="http://www.blogger.com/atom/ns#" term="Image Processing"/><title type='text'>Calculation of Discrete Fourier Transform(DFT) in C/C++ using Naive and Fast Fourier Transform (FFT) method</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div align=&quot;left&quot;&gt;Discrete Fourier Transform has great importance on Digital Signal Processing (DSP). There are many situations where analyzing the signal in frequency domain is better than that in the time domain. The Fourier Transform actually converts the function in the time domain to frequency domain,  some processing is done in the frequency domain, and finally, inverse Fourier transforms converts the signal back into the time domain. The term discrete means the signal is not continuous rather it is sampled by some sampling frequency i.e. only some samples are taken in a certain interval (also called period). The sampling frequency depends upon the frequency of the original signal and this must satisfy Nyquist criteria. A simple example of Fourier transform is applying filters in the frequency domain of digital image processing. Before looking into the implementation of DFT, I recommend you to first read in detail about the &lt;a href=&quot;http://en.wikipedia.org/wiki/Discrete_Fourier_transform&quot;&gt;Discrete Fourier Transform&lt;/a&gt; in Wikipedia. If you are already familiar with it, then you can see the implementation directly.  The 1 dimensional DFT can be calculated by using the following formula&lt;/div&gt;&lt;div align=&quot;left&quot;&gt;&lt;a href=&quot;http://lh3.ggpht.com/-mm0BC7g5Zaw/UZFLwvAPzoI/AAAAAAAAAlk/QeKQAGCCAH8/s1600-h/dfte11.jpg&quot;&gt;&lt;img alt=&quot;dfte&quot; border=&quot;0&quot; src=&quot;http://lh3.ggpht.com/-BuEe94NT8Jo/UZFLzmOPGqI/AAAAAAAAAls/gt5c2WuHwWM/dfte_thumb7.jpg?imgmax=800&quot; height=&quot;92&quot; style=&quot;border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline;&quot; title=&quot;dfte&quot; width=&quot;240&quot;&gt;&lt;/a&gt; &lt;/div&gt;&lt;/div&gt;&lt;a href=&quot;https://www.programming-techniques.com/2013/05/calculation-of-discrete-fourier.html#more&quot;&gt;Read more »&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://www.programming-techniques.com/feeds/611915916033260383/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://www.programming-techniques.com/2013/05/calculation-of-discrete-fourier.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/611915916033260383'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/8220923316510870669/posts/default/611915916033260383'/><link rel='alternate' type='text/html' href='https://www.programming-techniques.com/2013/05/calculation-of-discrete-fourier.html' title='Calculation of Discrete Fourier Transform(DFT) in C/C++ using Naive and Fast Fourier Transform (FFT) method'/><author><name>Bibek Subedi</name><uri>http://www.blogger.com/profile/15521941142151573500</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/-4cYm423CP3A/T-rEE9NfqOI/AAAAAAAAAYw/uD3BD-tD8nY/s1600/8a896692cba4831c1e4bf42a8757c288%253Fsize%253D420'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh3.ggpht.com/-BuEe94NT8Jo/UZFLzmOPGqI/AAAAAAAAAls/gt5c2WuHwWM/s72-c/dfte_thumb7.jpg?imgmax=800" height="72" width="72"/><thr:total>3</thr:total></entry></feed>