Hi,
I have made some sorting function based on finding largest element and swapping its place with last element of array and then searching largest element of rest of array and putting it on one place before last one and so on.
I am curious about is there a name for sorting of this type?
I searched Wikipedia, and the most similar sorting method seems to be a Heap sort.
Here is the sorting function I made:
int Biggest(int Niz[], int n){
int x= Niz[0];
for(int i=1;i<n;++i)
if(Niz[i]>x) x=Niz[i];
return x;
}
void Sort(int *Niz, int n){
int *temp=new int;
for(;n>1;--n){
*temp=Biggest(Niz,n);
for(int i=0;i<n;++i){
if((*temp)==Niz[i]){
Niz[i]=Niz[n-1];
Niz[n-1]=(*temp);
}
}
}
delete temp;
}
Does it suit with Heap Sort?
Thanks!