Results 1 to 4 of 4
  1. #1
    sara12345 is offline Member
    Join Date
    Dec 2009
    Posts
    59
    Rep Power
    0

    Default 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:
    Java Code:
    for( int x=0;x<vector.size();x++)	{    	    
     for ( int w=0;w< vector.size();w++){
    Collections.swap(vector, x, w);}}
    as I said before the swap method didn't provide me the result I want
    can somebody tell me how to do it please urgent

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    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.

  3. #3
    sara12345 is offline Member
    Join Date
    Dec 2009
    Posts
    59
    Rep Power
    0

    Default

    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

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

Similar Threads

  1. Vector<vector> loop thru
    By ocean in forum New To Java
    Replies: 11
    Last Post: 11-21-2009, 02:17 PM
  2. Java XML DOM/Transformer and attribute ordering
    By BeMathis in forum Advanced Java
    Replies: 0
    Last Post: 10-14-2009, 06:49 PM
  3. Replies: 1
    Last Post: 04-06-2009, 06:45 AM
  4. Problem with ordering for loops
    By ScaryJello in forum New To Java
    Replies: 3
    Last Post: 03-31-2009, 08:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •