Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Algorithm or Code for Possibilities

Algorithm or Code for Possibilities

Scheduled Pinned Locked Moved C#
algorithmstutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Silvyster
    wrote on last edited by
    #1

    Is there an algorithm where i could get all the possible sequence? Example: given is "abc" where the possible sequence are: "abc" "acb" "bac" "bca" "cba" "cab"

    L G 2 Replies Last reply
    0
    • S Silvyster

      Is there an algorithm where i could get all the possible sequence? Example: given is "abc" where the possible sequence are: "abc" "acb" "bac" "bca" "cba" "cab"

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi,

      Silvyster wrote:

      Is there an algorithm where ...

      Yes there is. In fact there are many. It is a nice occasion for a recursive one: to find a valid combination permutation of N symbols, first choose the leftmost symbol (a foreach loop could do that), then calculate the remaining collection and solve the problem for that smaller collection (with N-1 symbols) by recursion. If you keep the symbols ordered in some way (say alphabetical) the nice side-effect is all combinations permutations will come out in the same (alphabetical) order. And recursion is appropriate since the number of combinations permutations grows exponen- tially with the word length, i.e. your patience will run out long before you get a stack overflow. :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      Fixturized forever. :confused:


      modified on Friday, October 31, 2008 8:31 AM

      1 Reply Last reply
      0
      • S Silvyster

        Is there an algorithm where i could get all the possible sequence? Example: given is "abc" where the possible sequence are: "abc" "acb" "bac" "bca" "cba" "cab"

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #3

        What you are looking for is an algorithm for permutations. Go forth and search the web. :)

        Despite everything, the person most likely to be fooling you next is yourself.

        L 1 Reply Last reply
        0
        • G Guffa

          What you are looking for is an algorithm for permutations. Go forth and search the web. :)

          Despite everything, the person most likely to be fooling you next is yourself.

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          right. :doh:

          Luc Pattyn [Forum Guidelines] [My Articles]


          Fixturized forever. :confused:


          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups