logo

Crowdly

Browser

Add to Chrome

A complexidade temporal no pior caso do método algoritmoX é O( n ). // The wors...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

A complexidade temporal no pior caso do método algoritmoX é O( n ).

//

The worst-case time complexity of the method algoritmoX is O( n ).

    public int algoritmoX(int[] vec){

        int n = vec.length-1;

        return algoritmoXAux(vec, 0, n);

    }

    

    private int algoritmoXAux(int[] vec, int low, int high){

        if (low>=high)

            return vec[high];

               

        int mid = (low+high)/2;

        if (vec[mid] % 2 == 0)

            return algoritmoXAux(vec, low, mid);

        else

            return algoritmoXAux(vec, mid+1, high);

    }

0%
100%
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