Wednesday, July 11, 2012

Bubble Sort


Simplest sorting algorithm which is frequently used is Bubble sort. The bubble sort works on a fairly simple algorithm where items are sort by iterating down an array and sorted with the first element to the last, here we compare each set of value and then switch their positions if required. This same method is continue until the array is sorted. The maximum iteration can occur in a case where the array is in reverse order, where the first value needs to be swapped with the last value. In this case the maximum iteration required to sort the complete array will be same as the array length.
Here is a Simple demonstration of the code in C# where the for loop is used to perform the iteration and a temporary array is used to store the sorted values. 

The algorithm works on the principle of swapping the value by comparing them, here is a pictorail demonstration of the task. This will give a clear idea for the whole process.


 Here is the Implementation using the C# code

namespace BubbleSort
{
    class Program
    {
        static void Main(string[] args)
        {

            int i = 0, j = 0, t = 0;
            int[] unSortedArray = new int[20];
            for (i = 0; i < 10; i++)
            {
                Console.WriteLine("Enter Value p[{0}]:", i);
                unSortedArray[i] = int.Parse(Console.ReadLine());
            }
            // Sorting Algorithm  Starts here - Bubble Sort
            for (i = 0; i < 10; i++)
            {
                for (j = i + 1; j < 10; j++)
                {
                    if (unSortedArray[i] > unSortedArray[j])
                    {                       
                        t = unSortedArray[i];
                        unSortedArray[i] = unSortedArray[j];
                        unSortedArray[j] = t;
                    }
                }
            }
            Console.WriteLine("\n The sorted array:\n");

            for (i = 0; i < 10; i++)
            {
                Console.WriteLine("Sorted Array[{0}]={1}", i, unSortedArray[i]);
            }

            Console.WriteLine("n Please Press a Key to Exit");
            Console.ReadLine();
        }
    }
}


Hope this piece of code is very useful for you in creating your sort functionality. Please provide the valuable comment by which I can improve the performance and code structure.


Thanks
Anil Kumar Pandey
Microsoft MVP, Microsoft MCC,DNS MVM

Wednesday, July 4, 2012

New MVP Announce for July 2012


Hello Everyone, Greetings!!!!

I am very happy to share this news that the New MVP awards for July 2012 has been announced and the name of the new Community Rock star are :

1.      Abhimanyu Kumar Vatsa
2.      Joydeep Das
3.      Vidya Sagar Gudisa
4.      Dilip Pandey
5.      Pranay A. Rana

At the same time, Some of our fiends are no longer an MVP  but they will join us as MVP Alumni:

1.      Ravickumar Murugesan
2.      Praveen Srivatsa
3.      Vinod Unny
4.      Manan Kakkar
5.      Shoban Kumar
6.      Gaurav Anand
7.      Ambily  K K

We hope to see the wonderful alumni in the community and hope that they join us back soon. Please take a moment to welcome the new “Community Rockstars”. Congratulations once again...

Thanks
Anil Kumar Pandey
Microsoft MVP, Microsoft MCC,DNS MVM


Tuesday, July 3, 2012

Most Valuable Member (MVM of DNS)

Hi Friends,

I am extremely happy to inform you all that I have been selected as a Most Valuable Member (MVM) in one of the reputed dot net technical community site that is www.dotnetspider.com. This is the fourth consecutive year as MVM award from this site. I am thank full to all my dear friends and community members who have supported me.

Here is the certificate of appreciation.



Thanks again to all my dear friends.


Thanks
Anil Kumar Pandey
Microsoft MVP, Microsoft MCC,DNS MVM

Kontera