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

  • SEARCH
  • Home
  • 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 4041890
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:56:13+00:00 2026-05-20T12:56:13+00:00

I have problem in determining time complexities of algorithms. for(int i=0;i <n i++){} O(n)

  • 0

I have problem in determining time complexities of algorithms.

for(int i=0;i <n i++){}   O(n)

for(int i= 0 ;i<n ;i++){    O(n^2)
  for(int j=0;j<n;j++){ 

  }
}

Now for following code whats the complexity

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

is it O(2n) as it invloves 2 seperate loops?

what if i start j =5 to n?

  • 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-05-20T12:56:13+00:00Added an answer on May 20, 2026 at 12:56 pm

    There is no O(2n), it’s just O(n). In other words, it scales at the same rate as n increases.

    If it was a nested loop, it would be O(n2) but the presence of your {} empty blocks means it isn’t nested.

    And it makes no difference whether you start at one or five, it still scales with n, just with a slightly negative constant addition. Hence still O(n).

    The complexities O(n), O(cn) and O(n+c) (where c is a constant) are all equivalent. In addition, you also generally only use the term with the highest effect.

    So you won’t usually see O(7n3 + 3n2 + 12n + 2), that will be simplified to O(n3).

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

Sidebar

Related Questions

This has been bugging me for some time now. My problem is the following.
I have a problem in Determining Browsers. I've tried using navigator and well, it
I have a problem in determining when the audio.play() method done in playing mp3
I have the following: public ICollectionView Children { get { // Determining if the
I have a problem with determining the position of main-menu items after their translation.
Hallo All, Please help in determining the best procedure for the following problem. In
I have a strange problem with determining the position of elements with help of
I have problem with http://abfoodpolicy.com/ . In IE 8 and 9 the right sidebar
I have problem with my query on C, I’m using the oci8 driver. This
I have problem with repopulating form_upload after validation. Other input fields or selectboxes are

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.