Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8476595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:13:22+00:00 2026-06-10T18:13:22+00:00

According to my analysis, the running time of this algorithm should be N 2

  • 0

According to my analysis, the running time of this algorithm should be N2, because each of the loops goes once through all the elements. I am not sure whether the presence of the if statement changes the time complexity?

for(int i=0; i<N; i++){
    for(int j=1; j<N; j++){

        System.out.println("Yayyyy");
        if(i<=j){
            System.out.println("Yayyy not");
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:13:24+00:00Added an answer on June 10, 2026 at 6:13 pm
    • Tp: time it takes to print a constant text to standard output.
    • Ti: time it takes for all other operations inside the inner loop (predicate evaluation etc.).
    • To: time it takes for all operations inside the outer loop except the execution of inner loop (initializing counters etc.).
    • Tc: time it takes for setting up the process and every other bookkeeping

    Total running time will be Tc + N x (To + NxTi + N/2xTp).

    This is equal to Tc + NxTo + (Nx(N/2)) x (2Ti + Tp) which is bounded by K x (N^2) for values of K > Ti + Tp/2 as N goes to infinity. This boundary makes the time complexity still O(N^2).

    No, the if statement does not change the time complexity in this example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to the information on this page I was going to add Analysis Services
According to this SO post: How to check the TEMPLATE_DEBUG flag in a django
According to this post , IDEA uses Osmorc to run OSGi frameworks. It, in
According this article , generic JPA DAO(Data Access Object) is a pretty nice pattern.
According to this post in Recursive Descent vs. LALR , any LALR(k) can be
According to docs at http://code.google.com/p/minify/wiki/UriRewriting $min_serveOptions['rewriteCssUris'] = false; I should be able to add
Running Visual Studio 2008 Professional it is possible to enable static code analysis using
I recently came across the pandas library for python, which according to this benchmark
According To reflector , ExpandoObject Does implemenet IDictionary<string, object> How ever I have this
I have several test results of server response delay. According to our theory analysis,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.