//To sort an array of integers by not moving the element itself ..we
can only use array of pointers...to adjust the pointers
I have used bubble sort....but it only runs for the first pass when i
= 0 ..but not for further values of i
void sort(int A[])
{
int i ;
//int **a = &ptr[0];
for(i=0;i<MAX-1;i++)
{
cout<<"\n case number = "<<i;
for(int j = 0;j<MAX-i;j++)
{
if((*(ptr[j]))> (*(ptr[j+1]))) //this means A[j] > A[j+1]
{
int *a = ptr[j+1];
ptr[j+1] = ptr[j];
ptr[j] = a;
display();
}
}
}//end of outer loop
}//end of function
full code :----
http://ideone.com/IeSRQ
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.