Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 16th, 2006, 2:12 AM   #21
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5 bl00dninja is on a distinguished road
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.
bl00dninja is offline   Reply With Quote
Old Sep 16th, 2006, 5:16 AM   #22
Mocker
Hobbyist Programmer
 
Mocker's Avatar
 
Join Date: Oct 2005
Location: Indiana
Posts: 217
Rep Power: 0 Mocker is an unknown quantity at this point
Send a message via AIM to Mocker
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
Mocker is offline   Reply With Quote
Old Sep 16th, 2006, 8:05 AM   #23
Narue
Professional Programmer
 
Narue's Avatar
 
Join Date: Sep 2005
Posts: 419
Rep Power: 4 Narue is on a distinguished road
>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.
Narue is offline   Reply With Quote
Old Sep 18th, 2006, 12:38 AM   #24
sarumont
Hobbyist Programmer
 
sarumont's Avatar
 
Join Date: Apr 2004
Location: /dev/urandom
Posts: 154
Rep Power: 5 sarumont is on a distinguished road
Send a message via ICQ to sarumont Send a message via AIM to sarumont Send a message via Yahoo to sarumont
Moved to SW Design/Algorithms and made sticky. Excellent thread, guys.
__________________
"Time is an illusion. Lunchtime doubly so."
-the late, great Douglas Adams
sarumont is offline   Reply With Quote
Old Sep 18th, 2006, 12:59 AM   #25
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5 bl00dninja is on a distinguished road
Quote:
One question though, what the heck would we use this for?
actually, implementing and plotting these algorithms was an assignment i just had in class.
__________________
i put on my robe and wizard hat...

Have you ever heard of Plato, Aristotle, Socrates?...Morons.
bl00dninja is offline   Reply With Quote
Old Sep 18th, 2006, 10:05 AM   #26
RobEasy
Programmer
 
RobEasy's Avatar
 
Join Date: May 2006
Location: The US duhhhhh!
Posts: 42
Rep Power: 0 RobEasy is on a distinguished road
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!
RobEasy is offline   Reply With Quote
Old Oct 1st, 2006, 12:04 AM   #27
ZenMasterJG
Hobbyist Programmer
 
ZenMasterJG's Avatar
 
Join Date: Nov 2004
Location: Boston, MA
Posts: 148
Rep Power: 4 ZenMasterJG is on a distinguished road
Send a message via AIM to ZenMasterJG
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
ZenMasterJG is offline   Reply With Quote
Old Oct 1st, 2006, 8:55 AM   #28
Narue
Professional Programmer
 
Narue's Avatar
 
Join Date: Sep 2005
Posts: 419
Rep Power: 4 Narue is on a distinguished road
>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.
Narue is offline   Reply With Quote
Old Oct 1st, 2006, 9:44 AM   #29
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,031
Rep Power: 5 lectricpharaoh will become famous soon enough
Quote:
Originally Posted by RobEasy View Post
One question though, what the heck would we use this for?
Hint: it starts with 'sort', and ends with 'ing'.
Quote:
Originally Posted by Mocker View Post
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 ?
One possible approach might be to chop the data up into x subsets, and sort each subset on a separate CPU. However, I can only see this improving performance if a) your data set was large enough to justify the overhead (creating the threads for the separate processors, doing the initial data split, etc), b) if there were no significant issues with the CPUs sharing the memory bus (ie, each thread was more or less CPU-bound, and not memory bound, or if memory bound, could fit large chunks in an L1 or L2 cache), and c) the data would split into relatively equally-sized subsets (otherwise, you get one CPU sitting idle after sorting a dozen items, while another chugs away on several million).
__________________
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
lectricpharaoh is offline   Reply With Quote
Old Dec 21st, 2006, 8:11 PM   #30
kyndig
Newbie
 
Join Date: Jan 2006
Posts: 7
Rep Power: 0 kyndig is on a distinguished road
Radix > All
kyndig is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
sort and swap brad sue C 1 Mar 25th, 2006 6:33 AM
interpolation search on a million EverLearning C 24 Jun 15th, 2005 2:42 PM
threaded merge sort help AusTex C 1 May 1st, 2005 4:58 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:10 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC