[algogeeks] Re: How will you sort 1 million floating point numbers?

2010-10-18 Thread xyombie
On a single threaded architecture, I would use the quick sort: http://en.wikipedia.org/wiki/Quick_sort On a parallel architecture, I would use Parallel Sorting by Regular Sampling: https://agora.cs.illinois.edu/download/attachments/24348363/Sort+ParaProg(Quinn)chpt14.5.pdf In the case of

[algogeeks] Re: memory allocation

2010-07-25 Thread xyombie
Create your own malloc() free() functions. when you allocate memory, allocate a little bit extra memory to add a token of your choosing. When free'ing the memory, check that the token is still there. You are going to want to add the token to the beginning of the memory, and not at the end for

[algogeeks] Re: Write a C program to sort a stack in ascending order.

2010-07-17 Thread xyombie
What about a quick sort O(log n) void sort_stack(Stack *src, Stack *dst) { if(! src-IsEmpty() ) { Stack smaller, larger; int pivot = src-Pop(); while(! src-IsEmpty() ) { int tmp = src-Pop();