Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

137
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!