I am seeking assistance in determining the time complexity of a given source code, which appears to be of the order O(n^3). Could someone kindly assist me in evaluating its time complexity?:
public static int function(int[] arr, int index) {
if (index <= 0) {
return arr[0];
}
int one = function(arr, index - 1);
int two = function(arr, index - 2);
int three = function(arr, index - 4);
if (one > two) {
return one;
} else if (two > three) {
return three;
} else {
return one;
}
}
I expecting that the time complexity is o(n^3)