Results 1 to 4 of 4
- 01-08-2010, 09:47 PM #1
Member
- Join Date
- Dec 2009
- Posts
- 59
- Rep Power
- 0
getting all possible ordering of vector
hello
I need to find all possible order of a set of vector I mean if I have the following:
0
1
2
all posssible would be:
0 1 2, 1 0 2, 2 1 0, 1 2 0, 2 0 1, 0 2 1
I have tried to use the swap but I didn't get all possible set
I have used the following code:
as I said before the swap method didn't provide me the result I wantJava Code:for( int x=0;x<vector.size();x++) { for ( int w=0;w< vector.size();w++){ Collections.swap(vector, x, w);}}
can somebody tell me how to do it please urgent
- 01-08-2010, 09:59 PM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
If you stop and think about it there are size! different orderings, but you are only doing size^2 swaps, so that was never going to work.
This seems to be an extension of your thread swapping elements of vector. You're welcome, but couldn't you have explained there what you were trying to do? (the problem apparently is not redundancy but, rather, that you aren't doing enough swaps).
Consider recursion.
- 01-08-2010, 10:03 PM #3
Member
- Join Date
- Dec 2009
- Posts
- 59
- Rep Power
- 0
sorry! you are right after runing the program I have found that the swap is not the solution to my problem because I want to find all possible ordering set of vector and then try to order the elements of vector according to some critriea. but as I said the swap doesn't solve my problem because it doesn't find all possible ordering set. if you know how can I solve my problem please tell me
thanks
- 01-08-2010, 10:21 PM #4
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
Similar Threads
-
Vector<vector> loop thru
By ocean in forum New To JavaReplies: 11Last Post: 11-21-2009, 02:17 PM -
Java XML DOM/Transformer and attribute ordering
By BeMathis in forum Advanced JavaReplies: 0Last Post: 10-14-2009, 06:49 PM -
Vector<Point2D> list = new Vector<Point2D>();Is it possible for 15,000 Point2D obj???
By Mazharul in forum Java 2DReplies: 1Last Post: 04-06-2009, 06:45 AM -
Problem with ordering for loops
By ScaryJello in forum New To JavaReplies: 3Last Post: 03-31-2009, 08:20 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks