Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

136
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda