Hi guys I am practicing my algorithm and complexity theory. I want to know what is the order of complexity of the algorithm developed taking the x-axis as the size of the vector? (Big O notation). This is the piece of code that I took and Algorithm to return all combinations of k elements from n and just modify a little bit
import java.util.Arrays;
public class BigOExample {
public static void main(String[] args){
Integer[] arr = {12,24,31,43,55,61};
combinations2(arr, 4, 0, new Integer[4]);
}
static void combinations2(Integer[] arr, int len, int startPosition, Integer[] result){
if (len == 0){
System.out.println(Arrays.toString(result));
return;
}
for (int i = startPosition; i <= arr.length-len; i++){
result[result.length - len] = arr[i];
combinations2(arr, len-1, i+1, result);
}
}
}
Thank you very much!!