/* Ajith - Syntax Higlighter - End ----------------------------------------------- */

11.04.2013

Bubble Sorting

Bubble sort is one of the simple sorting algorithms and also popularly known as a Brute Force Approach. The logic of the algorithm is very simple as it works by repeatedly iterating through a list of elements, comparing two elements at a time and swapping them if necessary until all the elements are swapped to an order.

For e.g. if we have a list of 10 elements, bubble sort starts by comparing the first two elements in the list. If the second element is smaller than the first element then it exchanges them. Then it compares the current second element with the third element in the list. This continues until the second last and the last element is compared which completes one iteration through the list. By the time it completes the first iteration the largest element in the list comes to the rightmost position.

Image courtesy from Annieink.com

The algorithm gets its name as we start from lowest point and “bubble up” the higher elements to the highest point in the list. We can also follow other approach where we start from highest point and “bubble down” lowest elements in the list. Since it only uses comparisons to operate on elements, it is a comparison sort.

8.13.2013

Reality of a Software Project

That's the reality I faced in real world crappy planning of Software Project. As a Developer we never have "FREE TIME" ..

Reality of a Software Project

6.10.2013

How to narrate a story to computer scientist


If it brings back old memories or a smile then I hope you understood the characters in STORY.

3.15.2013

Death of Google Reader - Journey towards alternatives

Flashback

Long Long ago when INTERNET is booming up with so many websites its really hard to follow the interesting one. Its quite clumsy to go around miliions of sites to check for new posts.

Am I Doomed ?

No, you are not. RSS feed mechanism is the answer.


Just follow the RSS feed of your favourite site and the RSS reader will maintain the unread articles, favourite articles and so on. Voilla simple and effective solution to follow various sites.

3.13.2013

Divide a number by 3 without using any arithmetic operators

How to divide a number by 3 without using operators + - / * %

NOTE: I am just trying to collect various answers down in this post available across multiple sites in internet as mentioned in references.

Solution 01:
#include <stdio.h>
#include <stdlib.h>

int main()
{
    FILE *fp=fopen("temp.dat","w+b");
    int number=12346;
    int divisor=3;
    char *buf = calloc(number,1);
    fwrite(buf,number,1,fp);
    rewind(fp);
    int result=fread(buf,divisor,number,fp);
    printf("%d / %d = %d", number, divisor, result);
    free(buf);
    fclose(fp);
    return 0;
}