I had this lying around. You can overload the function easily enough. Stype needs a comparison if you don't use simple types like double. Edit, I stuck a 3 and a 7 in there for the tiny list size. Also keep the simple stuff here, the advanced stuff over in general ... duplicate posting isn't helpful. I don't remember exactly how this works, youll have to muddle it out and explain it to your professor, but its just a simple sort.
const int harr[] =
{
0, /*terminal condition for sort */
1, 3,7,
10,
53,
105,
542,
1047,
6239,
16256,
56720,
134096,
579823,
1000021,
5430201,
999999999 /*terminal condition for find index */
};
void ssort(stype *list , const int size);
void ssort(stype *list , const int size)
{
int i;
int j, dx = 1;
while(size > harr[dx])
{
dx++; /*get index in sequence, +1 */
}
I knew you could figure it out once you got into it. Now, can you explain it? Try stepping through it to see how it works, then see if you can figure out which sorting algorithm it is and what its big-o complexity might be etc. I normally won't give code until someone puts a little effort out there, but sorts are all over the web anyway so there is not stopping someone from lifting code for that. So instead I gave you something that is a bit of a puzzle to learn from. What is the purpose of the global array?