generation/bugs-QuixBugs/bugs/SUBSEQUENCES.java/src/java_programs/SUBSEQUENCES.java
<filename>generation/bugs-QuixBugs/bugs/SUBSEQUENCES.java/src/java_programs/SUBSEQUENCES.javapackage java_programs;
import java.util.*;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author derricklin
 */
public class SUBSEQUENCES {
    public static ArrayList<ArrayList> subsequences(int a, int b, int k) {
        if (k == 0) {
            return new ArrayList();
        }

        ArrayList ret = new ArrayList(50);
        for (int i=a; i<b+1-k; i++) {
            ArrayList base = new ArrayList(50);
            for (ArrayList rest : subsequences(i+1, b, k-1)) {
                rest.add(0,i);
                base.add(rest);
            }
            ret.addAll(base);

        }

        return ret;
    }
}
