title: JAVA Algorithm for a function that prints 3 element subsets?
body: <p>I got a question and I am writing an algorithm for that. I am given the first line which is int Print-3-element-subsets(int n, int s[]). My algorithm doesn't seem correct. Please help me. </p>
  
  <p>Write a function that prints out all 3-element subsets of the elements in array S (indexed from 1 to n). don’t print the same subset twice, and make sure each subset has exactly 3 elements.</p>
  
  <pre><code>int Print-3-element-subset(int n, int s[])
  {
      for(int i =0; i&lt;n; i++)
  
           for(int j=n; j&lt;i; j--)
  
              for(int k =n ; k&lt;i; j--)
  
                  print("{"+s[i]+ ", "+s[j]+"," +s[k]+"}");
  } 
  </code></pre>