Data Structures and Algorithms Discussion Board
September 02, 2010, 08:43:43 PM *
Welcome, Guest. Please login or register.
Login with username, password and session length
News: Looking for a reliable webhosting provider? Read HostGator review to find 7 arguments in support of HostGator.
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Algo to find Permutation of say [a,b,c,d]  (Read 2633 times)
jackdaniels
Newbie
*

Rating: 0
Offline Offline

Posts: 1


« on: October 30, 2009, 01:46:05 AM »

I want to find the permutations of say 4 letters - a, b, c, d taken from 1 at a time to the number of elements (4 in this case).  Need to print out the possible values - What is the best algoritm to achieve this?

e.g. result should have:
a
ab
ba
abc
abd
bda
bdc
bdca
abcd
b
bc
...
etc
(all possibilities that can be made with the elements)
Logged
Denis
Newbie
*

Rating: 0
Offline Offline

Posts: 21


« Reply #1 on: November 21, 2009, 04:40:39 AM »

You have to generate combinations C(4, 1), ... C(4, 4) with only difference, that now order matters [a, b] != [b, a]. If you algorithm's code in Java/C++, let me know.
Logged
Pages: [1]
  Print  
 
Jump to:  

 
Partners Ads        teaching the science of cme