Home » Community » Forums » » Quicksort
  Intel sponsors gamedev.net search:   
[Control Panel] [Register] [Bookmarks] [Who's Online] [Active Topics] [Stats] [FAQ] [Search]

Add Forum to Favorites |  Send Topic To a Friend | View Forum FAQ | Track this topic


 Last Thread Next Thread 
 Quicksort
Post Reply 
This was EXTREMLY helpful but still I cannot get my QuickSort Function to work
Could some experienced programmer out there please assist me?

 User Rating: 1015    Report this Post to a Moderator | Link

hi,

i want to move this character, but i can't do it.
does anyone can help me ?

plz.



 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

well, i definitely wouldn't consider myself an experienced programmer but here is a working c++ implementation of the quicksort algorithm:

template <class Type> inline static void swap(Type *array, int i, int j)
{
Type temp = array;
array[i] = array[j];
array[j] = temp;
}

template <class Type> void qsort(Type *array, int low, int high)
{
if (low < high)
{
int l = low;
int h = high+1;
Type elem = array[low];

for (;
{
while (array[++l] < elem);
while (array[--h] > elem);

if (l<h)
swap<Type> (array, l, h);
else break;
}

swap<Type> (array, low, h);
qsort<Type> (array, low, h-1);
qsort<Type> (array, h+1, high);
}
}


hope i could help you!
cheers m00c


 User Rating: 1015    Report this Post to a Moderator | Link

All times are ET (US)

Post Reply
 Last Thread Next Thread 
Forum Rules:
You may not post new threads
You may post replies
You may not edit your posts
You may not use HTML in your posts
Jump To:
Administrative Options: