Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

142
Visualizações
How Can I find the Worst-case Time Complexity of a code like this

This code snippet here might not work very well but the idea is that I want to know how to find the worst-case time complexity when you have a Sorting algorithm (mergeSort) function inside of a function and with two for loops. I'm now trying to understand how to find the worst-time complexity and I know that two nested loops will give a quadratic function of O(n^2). I hope someone can throw more light on this for me and sorry if I broke any rules in the process.

function part(vector){

    var n = vector.length;
    
    if (n == 0){

      return False;
    }
     
    var vector = MergeSort(vector);

    for(var i=0; i < n; i++) {

        for(var j = 0; i< n; j++) {

            var a = i;
            var b = n;
            while (a <= b){
                var c = math.floor((a + b)/2);

                if (vector[c] = -vector[i] - vector[j]){
                    return True;
                }
                else if (vector[c] < -vector[i] -vector[j]){
                    a = c + 1;
                {
                 else {
                    b = c -1;
                }
                    
             }
        }
    {
    return False;

}

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda