Tuesday, May 24, 2016

DataStructure and Algorithm in Bengali

DataStructure and Algorithm in Bengali

By: Md. Delwar Hossain

Lecturer, Dept. of CSE, Asian University of Bangladesh

Visit: ডাটা স্ট্রাকচার এন্ড এ্যালগরিদম

Sunday, September 7, 2014

Quick Sort

//Program Using Quick Sort

#include
using namespace std;
int part_a(int * input, int l, int r)
{
int pivot=input[l];
while(lpivot)
{
r--;
}
swap(input[l],input[r]);
}
if(l>r)
{
swap(input[l],input[r]);
}
swap(pivot,input[r]);
return r;
}
int quickSort(int *input,int l, int r)
{
if(l<r)
{
int s=part_a(input, l, r);
quickSort(input,l,s-1);
quickSort(input,s+1,r);
}
}
int main(string args[])
{
int a[9]={6,3,4,2,7,1,5,9,8};
quickSort(a,0,8);
for(int i=0;i<9;i++)
{
cout<<a[i]<<endl;
}
}

Shell Sort

//Program Using Shell Sort

include
using namespace std;
main()
{
int arr[5]={4,2,7,1,9};
int i,j,k,num=5,t;
for(i=num/2;i>0;i=i/2)
{
for(j=i;j=0;k=k-i)
{
if(arr[k+i]>=arr[k])
break;
else
{
t=arr[k];
arr[k]=arr[k+1];
arr[k+1]=t;
}
}
}
}
for(int d=0;d<num;d++)
cout << arr[d] << endl;
}