0

How to conditionally traverse through a linked HashSet and get resultant

Given set A = {A, B, C};

Given Set B = {D, E, F}; <- Keeping this set unchanged 

Iterating in order,

node A -> 
  if(! Some condition) {
      skip node A and Goto B;
  }else{
     {D, E, F,A}, {D, E, F, A,B}, {D,E,F,A,C}; 
  }
node B -> 
  if(! Some condition) {
        skip node B and Goto C;
  } else{
    {D, E, F,B}, {D, E, F,B,C}
  }
node C -> 
  if(! Some condition) {
        exit;
  }else{
      {D, E, F,C}
  }

So the result would be,

   {D, E, F, A}
   {D, E, F, A, B}
   {D, E, F, A, C}
   {D, E, F, B}
   {D, E, F, B, C}
   {D, E, F, C}
   {D, E, F, A, B, C}
BalaajiChander
  • 139
  • 3
  • 21
  • 2
    You cannot define a problem through an example. Please be more precise. To solve a problem through programming, one has to write some code. Show us what you got so far and ask more specific questions. Otherwise we are unable to help. – Turing85 Apr 12 '18 at 15:31
  • [Getting permutations of a set](https://stackoverflow.com/questions/11208446/generating-permutations-of-a-set-most-efficiently) - it's written for C# but you should be able to adapt it for Java. – jsheeran Apr 12 '18 at 15:31
  • Your expected result does not consider conditions, and has one more set compared to "example". And it's undefined what happens if `Some condition` evaluates to `true`. Does iteration continue? Or algorithm has to `exit`? I'm with Turing85 on this: you should actually define what you want algorithmically. – M. Prokhorov Apr 12 '18 at 15:41

0 Answers0