![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#21 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 6
![]() |
i'll look into your stuff narue...really neat!
yeah, i think a move into the algorithm page would be great, this is a really good thread.
__________________
i put on my robe and wizard hat... Have you ever heard of Plato, Aristotle, Socrates?...Morons. |
|
|
|
|
|
#22 |
|
Hobbyist Programmer
|
oo nice. Question for you people good with them sorts, do you know how to specifically target multiple cpu's in a sort in order to maximize their use (dual core up to large clusters)? I image it would mostly be useful for larger cpu intensive sorts, sort of a divide and conquer by setting multiple threads sorting one portion at a time ?
__________________
#programmingforums relay - http://thegupstudio.com/cgi-bin/pforelay.cgi freelance scripts - http://ryanguthrie.com/index.html |
|
|
|
|
|
#23 |
|
Professional Programmer
![]() Join Date: Sep 2005
Posts: 419
Rep Power: 4
![]() |
>do you know how to specifically target multiple cpu's in a sort in order to maximize their use
I don't understand your question. Do you want to specialize an algorithm for high performance machines or make it usable on more machines? You seem to be asking for both. >sort of a divide and conquer by setting multiple threads sorting one portion at a time ? Perhaps in a huge distributed sort across multiple machines, but that's typically where one would use an external sort with each process (rather than dividing the work of a single algorithm with threads) and then merging the results together into one. No, individual algorithms are typically optimized by making them cache aware and taking advantage of branch prediction.
__________________
Even if the voices aren't real, they have some pretty good ideas. |
|
|
|
|
|
#24 |
|
Hobbyist Programmer
|
Moved to SW Design/Algorithms and made sticky. Excellent thread, guys.
![]()
__________________
"Time is an illusion. Lunchtime doubly so." -the late, great Douglas Adams |
|
|
|
|
|
#25 | |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 6
![]() |
Quote:
__________________
i put on my robe and wizard hat... Have you ever heard of Plato, Aristotle, Socrates?...Morons. |
|
|
|
|
|
|
#26 |
|
Programmer
Join Date: May 2006
Location: The US duhhhhh!
Posts: 42
Rep Power: 0
![]() |
I wish I was still doing CS, I can barely understand whats going on. I do know what the sorting techs are now. I guess for me it seems to be an abstract thing that I don't understand yet.
Anyways, this is some grand stuff!
__________________
Work Hard... Play Harder! |
|
|
|
|
|
#27 |
|
Hobbyist Programmer
|
For your edu-tainment, I present, BOGOSORT!
(Implemented (badly) in Java for extra points!) import java.util.Random;
public class Bogosort {
public static void main(String[] args) {
int[] sort={5,7,3,9};
boolean[] flag=new boolean[sort.length];
int[] sorted=new int[sort.length];
Random gen=new Random();
boolean done=false;
int choice=gen.nextInt(sort.length);
while(!done) {
for(int n=0; n<flag.length; n++) {
flag[n]=false;
}
for(int i=0; i<sort.length; i++) {
while(flag[choice]==true) {
choice=gen.nextInt(sort.length);
}
flag[choice]=true;
sorted[i]=sort[choice];
}
int last=sorted[0];
for(int a=0; a<sort.length; a++) {
if(sorted[a]>=last) {
done=true;
last=sorted[a];
} else {
done=false;
break;
}
}
}
for(int b=0; b<sort.length; b++) {
System.out.println(sorted[b]);
}
}
}Oh... you said efficient? Erm... Well, technically speaking, in the best case it'll do O(n)! .... Nevermind. :p |
|
|
|
|
|
#28 |
|
Professional Programmer
![]() Join Date: Sep 2005
Posts: 419
Rep Power: 4
![]() |
>Erm... Well, technically speaking, in the best case it'll do O(n)!
In the best case every sort is O(1), assuming you subscribe to the quantum multiverse theory.
__________________
Even if the voices aren't real, they have some pretty good ideas. |
|
|
|
|
|
#29 | |
|
SEXY SHOELESS GOD OF WAR!
![]() Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,195
Rep Power: 5
![]() |
Hint: it starts with 'sort', and ends with 'ing'.
![]() Quote:
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
|
|
|
|
|
|
#30 |
|
Newbie
Join Date: Jan 2006
Posts: 7
Rep Power: 0
![]() |
Radix > All
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| sort and swap | brad sue | C | 1 | Mar 25th, 2006 7:33 AM |
| interpolation search on a million | EverLearning | C | 24 | Jun 15th, 2005 3:42 PM |
| threaded merge sort help | AusTex | C | 1 | May 1st, 2005 5:58 PM |