Wednesday, February 23, 2011

Meaning of education to me...

From the very beginning of my graduation day, i was in a dilemma about the meaning of education. Education, to me is an enabler, and all other means to educate people are facilitators. i was baffled by the very basic question what i will be able to do hands-on after i got a BE degree. i didn't want to become a theory-mugging Babu like so many engineering graduates in India. To me if a software engineer is not able to write good programs of a running application, there is no meaning of his education. it does not matter how much theory one churns out, the way to practice that theory should be the motto of education...

As Swami Vivekananda said, "We may talk and reason all our lives, but we shall not understand a word of truth, until we experience it ourselves. You cannot hope to make a man a surgeon by simply giving him a few books. You cannot satisfy my curiosity to see a country by showing me a map; I must have actual experience. Maps can only create curiosity in us to get more perfect knowledge. Beyond that they have no value whatever... "

i am damn sure if someone looks into the IT industry, he will find lot of middle level managers and senior managers who just can't decipher a simple programming concept... They can be termed as Babus in the IT industry.. if an automobile engineer has to call a mechanic every time his car falters, his engineering degree does not serve the basic purpose...

Here in India we give more importance to marks... A student scoring 90% might not be an effective engineer...i know there are a number of engineers who would not have become engineers had they been guaranteed jobs in other industries...i know there are few people who want others to remain in dark and make profit out of their ignorance... under any circumstances they cannot be termed as good human beings...

thats the only reason probably i have embraced open source technologies to work on my software passion... because it gives freedom... i think FOSS is more about freedom than about free of cost...however, there are some limitations in the open source technologies as well... the limitation is that one has to overcome a steep learning curve to contribute a little to the learning society... and there is no hand-holding for a new comer... so far i have just used some of the open source technologies like Ubuntu, eclipse, android... but i have not been able to contribute any thing in terms of bug fixing of an open source project... however, i try to contribute to the learning society, in whatever little form it may be, through my technical blog...

i know i am an insignificant guy to change the way education is being practiced here in India...i know its not easy to become Jonathon Livingstone Seagull...  however, i want someone influential to think the way i have thought about education....

Monday, December 27, 2010

Freeware Android Paint with source code...

Here is one of my freeware android apps called AndroidPaint.


Using the Android Paint app, one can draw geometrical shapes and free hand drawing on an Android device. In the future version i will refine the app to give the user more drawing options and more regular shapes to draw.

To start with, one will have to choose from the menu options and then draw.

The screenshot of this application is as follows:


Source Code:
https://gitlab.com/som.mukhopadhyay/AndroidPaint

There are lots of scopes to re-factor this application... for example we can introduce a singleton factory class which will be responsible for creating different shapes... i thought of making the source code available to everyone after i did these kinds of refactoring... but i have lost the momentum... it will be really nice if someone works upon these...

Tuesday, September 28, 2010

Merge Sort - for my students...

Using divide-and-conquer policy we can solve a sorting problem. The divide-and-conquer method suggests the sorting algorithm with the following structure.: if n is one, terminate; otherwise partition the collection of elements into two or more sub collections.; sort each; combine the sub collections into a single sorted collection.


It can be depicted as follows:


void Sort(a[], n)
{
    if(n>= k) { //k is global
        i = n/k;
        j = n-i;
    Let A consist of the first i elements in a[]
    Let B consists of the remaining j elements in E
    Sort(A,i);
    Sort(B,j);
    merge(A,B,a,i,j); //merge A and B into a[]
}
 else sort a[] using insertion sort.
}


In the above pseudo code, if we make k = 2, we get merge sort.

The complete source code of Merge Sort can be found here.


Analysis of Merge Sort:

From the following algorithm of Merge Sort, the run time T(n) can be deduced as follows:

void MergeSort(int a[], int low, int high)
{
int mid;
if(low(high))
{
mid = (low+high)/2; ==> Θ(1)
MergeSort(a,low,mid); ==>T(n/2)
MergeSort(a,mid+1,high);==>T(n/2)
merge(a,low,mid,high);==>Θ(n)
}
}

Therefore we can write T(n) = 2T(n/2) + Θ(n)

Comparing it with the Master theorem, we get a = 2, b  = 2 and d = 1. Hence a = bd which means it is the second condition of the Master Theorem.

Thus we get T(n) = Θ (n log n)

Friday, September 24, 2010

Quick Sort - for my students...

Quick Sort is a sorting algorithm where we apply Divide and Conquer policy. In this sorting algorithm, the n elements to be sorted are partitioned into three segments - a left segment, a middle segment and a right segment. The middle segment is called pivot. The middle segment exactly contains one element. The partition is done in such a way so that all the elements in the left segment have key less than the pivot and all the elements in the right segment have keys greater than the pivot. As a result, the left segment and the right segment can be sorted independently.

The basic principle of Quick sort is as follows:

  • Select an element from a[0:n-1] for middle. This element is called pivot.
  • Partition the remaining element in such a fashion that all elements in the left of the pivot have keys less than the pivot, and all the elements in the right segment have keys greater than the pivot.
  • Sort left segment using quick sort recursively
  • Sort right segment using quick sort recursively
  • The answer will be left followed by middle followed by right.

The algorithm of the quick sort can be found here.

Debugging of the Algorithm of the code:

Step I: To begin with we get m = 0, n = 6, hence k = 3. After doing swap(&list[m],&list[k]), we get key = 5. The following two steps make i = 1 and j = 6.

Step II: Now the loop starts.

II while loop fails as list[i] (7) is not less than key (5). Hence i does not increase and it remains 1. The III while loop succeeds (as list[j]  > key)and hence j is decremented. So j becomes 5. In the next iteration of the III while loop, the list[j]>k condition fails, hence j remains 5 and we exit the III while loop. So we exchange list[i] and list[j] and the array becomes {5,1,8,3,2,7,9}

Next the II while loop succeeds and we increment i. Hence i becomes 2. The III while loop also succeeds and hence j becomes 4. So list[i] = list [2] = 8 and list[j] = list[4] = 2. So when we swap between list[i] and list[j], the array becomes list {5,1,2,3 8,7,9}.

Next the II while loop succeeds two times and we get i = 4. The III while loop also succeeds and we get j = 3. As j becomes larger than i, we come out of the I while loop.

Next we do swap(&list[m],&list[j]). And the list becomes list {3,1,2,5,8,7,9}

After that we recursively sort list{3,1,2}, the left segment and list{8,7,9}, the right segment.

See how all the elements of the left segment are less than 5 and all the elements in the right segment are greater than 5.

This is how we achieve the Quick Sort.

Sunday, September 19, 2010

Pointer Semantics Vs Value Semantics

Value semantics means we directly deal with the values and we pass copies of that value around. We can say that nobody will change the value.

However, in pointer semantics we deal with pointer, and anyone can change the value at the pointer location.

Consider the following program.

/*
 * main.c
 *
 *  Created on: Sep 18, 2010
 *      Author: administrator
 */

#include

void f (int * p, int * q) {
p = q;
*p = 2;
}

int i = 0, j = 1;


int main ( )
{
f(&i, & j);
printf("%d %d\n", i, j) ;
return 0;
}

The result will be 0 and 2. Why? Let me explain it to you.

We have two global variable i and j and we pass the pointer of these two variables to the function f.  When we do p = q, we actually loose the reference of i, and we get two pointers namely p and q both pointing to j. then when we do * p = 2, we actually change the value of j to 2. 

The whole thing can be depicted by the following diagram...



However, as we lost the reference of i in the step p = q, in the main program, the value of i that gets printed is the global variable that is 0. Hence we get the result as i = 0 and j = 2.

Hope this explains the pointer arithmetic to my students...

Friday, August 13, 2010

For my Microprocessor Students

I got this resource by googling. Hope this helps the student community.

Microprocessor Training

A good simulator for 8085 programming on PC is GNUSIM8085 and it is available at http://gnusim8085.org/


The interface of GNUSIM8085 looks like the following.