logo

Crowdly

Browser

Add to Chrome

Qual é a complexidade temporal do método algoritmoZ, se vec está totalmente pree...

✅ 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 algoritmoZ, se vec está totalmente preenchido e tem k elementos? //

What is the time complexity of the method algorithmZ, if the array vec is full and has k elements?

     public int algoritmoZ(int[] vec, int n) {

        int comp = vec.length-1;

        return algoritmoZAux(vec, 0, comp, n);

     }

     private int algoritmoZAux(int[] vec, int low, int high, int n){

        int mid = 0;

        if (high > low) {

            mid = (low+high)/2;

            return Math.max(algoritmoZAux(vec, low, mid, n), algoritmoZAux(vec, mid+1, high, n));

        }

        if (low>high)

            return 0;

        else //(low == high)

            if (vec[high] > n)

                return 1;

            else

                return 0;

     }

100%
0%
0%
0%
0%
More questions like this

Want instant access to all verified answers on moodle.fct.unl.pt?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome