Tuesday, January 31, 2012
Create a URL Shorte by php
Today I have create a code to make short url from a long url. So, you should not use others short url provider service....demo is here
Quick sort in c programming
Root function of quick sort:
[sourcecode language="c"]
void quickSort(int A[] , int left , int right)
{
int pivot , l_hold , r_hold;
l_hold = left;
r_hold = right;
pivot = A[left];
while(left < right)
{
while((A[right] >= pivot) && (left < right))
right--;
if(left != right)
{
A[left] = A[right];
left++;
}
while((A[left] <= pivot) && (left < right))
left++;
if(left != right)
{
A[right] = A[left];
right--;
}
}
A[left] = pivot;
pivot = left;
left = l_hold;
right = r_hold;
if(left < pivot)
quickSort(A , left , (pivot-1));
if(right > pivot)
quickSort(A , (pivot+1) , right);
}
[/sourcecode]
Full code of quick sort:
[sourcecode language="c"]
void quickSort(int A[] , int left , int right)
{
int pivot , l_hold , r_hold;
l_hold = left;
r_hold = right;
pivot = A[left];
while(left < right)
{
while((A[right] >= pivot) && (left < right))
right--;
if(left != right)
{
A[left] = A[right];
left++;
}
while((A[left] <= pivot) && (left < right))
left++;
if(left != right)
{
A[right] = A[left];
right--;
}
}
A[left] = pivot;
pivot = left;
left = l_hold;
right = r_hold;
if(left < pivot)
quickSort(A , left , (pivot-1));
if(right > pivot)
quickSort(A , (pivot+1) , right);
}
[/sourcecode]
Full code of quick sort:
Selection sort in c programming
Root function of selection sort:
[sourcecode language="c"]
void Selection_Sort(int A[] , int N)
{
int i , temp , Loc ;
for(i=0 ; i<(N-1) ; i++)
{
Loc = Minimum(A , i , N);
temp = A[i];
A[i] = A[Loc];
A[Loc] = temp;
}
}
[/sourcecode]
Full code of selection sort:
[sourcecode language="c"]
void Selection_Sort(int A[] , int N)
{
int i , temp , Loc ;
for(i=0 ; i<(N-1) ; i++)
{
Loc = Minimum(A , i , N);
temp = A[i];
A[i] = A[Loc];
A[Loc] = temp;
}
}
[/sourcecode]
Full code of selection sort:
Merge-Sort in C Programming
Main code of merge sort:
[sourcecode language="c"]
void mergeSort(int a[], int n) {
int b[100];
int l = 1;
while(l<n) {
mergePass(a, l, n, b);
mergePass(b, 2*l, n, a);
l = l*4;
}
}
[/sourcecode]
Full code of merge sort:
[sourcecode language="c"]
void mergeSort(int a[], int n) {
int b[100];
int l = 1;
while(l<n) {
mergePass(a, l, n, b);
mergePass(b, 2*l, n, a);
l = l*4;
}
}
[/sourcecode]
Full code of merge sort:
Saturday, January 28, 2012
Animated Share Buttons with CSS & jQuery
Thursday, January 26, 2012
Insertion sort in programming
Function of Insartion sort:
[sourcecode language="c"]
void Insertion_Sort(int A[] , int N)
{
int i , j , temp ;
for(i=2 ; i<N ; i++)
{
temp = A[i];
j = i-1;
while(temp < A[j])
{
A[j+1] = A[j];
j--;
}
A[j+1] = temp;
}
}
[/sourcecode]
[sourcecode language="c"]
void Insertion_Sort(int A[] , int N)
{
int i , j , temp ;
for(i=2 ; i<N ; i++)
{
temp = A[i];
j = i-1;
while(temp < A[j])
{
A[j+1] = A[j];
j--;
}
A[j+1] = temp;
}
}
[/sourcecode]
Subscribe to:
Posts (Atom)