Thursday, January 25, 2007

VS templates not working? Easy to get things back.

Recently I had to work with window SharePoint Service 3.0 and its development. I download the visual studio 2005 project templates for SharePoint development. I downloaded the project msi from Microsoft download site.

Installed in my local computer… but when I opened the IDE2005 project templates are not there…..

I got confused… and try reinstall the msi… but noting happed… I went to google and found few people is also suffering from this problem… the problem is my vs2005 is installed in different drive other that “c:\” and the installed temples are in default “c:\”… and then I moved my template in the drive where the IDE2005 is installed….

Location of the project templates is [your dive letter]:\Program Files\Microsoft Visual Studio 8\Common7\IDE…

There were two directories one if project template and other is item template… last thing that I did is to make ide identity the project templates….

For this I had to just a command in vs2005 comma prompt..

devenv /installvstemplates

I found help from the following forum… please go there for more detailed discussion…

Hope this will help someone someday….

Friday, January 5, 2007

Bubble Sort


Bubble sort, also known as sinking sort, is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted. The algorithm gets its name from the way smaller elements "bubble" to the top of the list. Because it only uses comparisons to operate on elements, it is a comparison sort. Although the algorithm is simple, it is not efficient for sorting large lists; other algorithms are better.

Pseudo Code

The pseudo code of the bubble sort is given bellow.

procedure bubbleSort( A : list of sortable items )
swapped = false
for i = 1 to length(A) - 1 inclusive do:
if A[i-1] > A[i] then
swap( A[i-1], A[i] )
swapped = true
end if
end for
until not swapped
end procedure


Bubble sort has worst-case and average complexity both О(n2), where n is the number of items being sorted. There exist many sorting algorithms with substantially better worst-case or average complexity of O(n log n). Even other О(n2) sorting algorithms, such as insertion sort, tend to have better performance than bubble sort. Therefore, bubble sort is not a practical sorting algorithm when n is large.

The only significant advantage that bubble sort has over most other implementations, even quicksort, but not insertion sort, is that the ability to detect that the list is sorted is efficiently built into the algorithm. Performance of bubble sort over an already-sorted list (best-case) is O(n). By contrast, most other algorithms, even those with better average-case complexity, perform their entire sorting process on the set and thus are more complex. However, not only does insertion sort have this mechanism too, but it also performs better on a list that is substantially sorted (having a small number of inversions).


Simulation #1:




More online simulation


Implementations of the bubble sort is given bellow. For now we have only three supported language, in future we would try to incorporate more implementations.

Code Sample in “c”

Real implementation in c is given bellow.


void bubble(int a[],int n)
int i,j,t;


}//end for 1.

}//end function.

void main()
int a[100],n,i;


printf("\n\n Enter integer value for total no.s of elements to be sorted: ");

for( i=0;i<=n-1;i++)
{ printf("\n\n Enter integer value for element no.%d : ",i+1);


printf("\n\n Finally sorted array is: ");
for( i=0;i<=n-1;i++)

} //end program.

Code Sample in “c++”

Bellow a simple implementation of bubble sort in c++ is given.

#include <stdio.h>
#include <iostream.h>

void bubbleSort(int *array,int length)//Bubble sort function
int i,j;
int temp=array[i]; //swap

void printElements(int *array,int length) //print array elements
int i=0;

void main()
int a[]={9,6,5,23,2,6,2,7,1,8}; // array to sort
bubbleSort(a,10); //call to bubble sort
printElements(a,10); // print elements

Code Sample in “c#”

The c# implementation is given bellow.

namespace AllAlgorithm
public class BubbleSort
private readonly int[] _samples = new int[100];
private int x;
public void SortArray()
int i;
int j;
for (i = (x - 1); i >= 0; i--)
for (j = 1; j <= i; j++)
if (_samples[j - 1] > _samples[j])
int temp = _samples[j - 1];
_samples[j - 1] = _samples[j];
_samples[j] = temp;