✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
Qual é a complexidade temporal do método algoritmoX, se vec está totalmente preenchido e tem k elementos? //What is the time complexity of the method algorithmX, if the array vec is full and has k elements?
public int algoritmoX(int[] vec, int n){ int comp = vec.length-1; return algoritmoXAux(vec, 0, comp, n); } private int algoritmoXAux(int[] vec, int low, int high, int n){ if (low>high) return 0; if (low == high) { boolean res = vec[high] == n; if (res) return 1; else return 0; } int mid = (low+high)/2; return Math.min(algoritmoXAux(vec, low, mid, n), algoritmoXAux(vec, mid+1, high, n)); }