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 6894603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:48:12+00:00 2026-05-27T06:48:12+00:00

I need help understanding/doing Big O Notation. I understand the purpose of it, I

  • 0

I need help understanding/doing Big O Notation. I understand the purpose of it, I just don’t know how to “determine the complexity given a piece of code”.

Determine the Big O notation for each of the following

a.

n=6;
cout<<n<<endl;

b.

n=16;
for (i=0; i<n; i++)
    cout<<i<<endl;

c.

i=6;
n=23;
while (i<n) {
    cout<<i-6<<endl;
    i++;
}

d.

int a[ ] = {1, 3, 5, 7, 9, 11, 13, 15, 17, 19};
n=10;
for (i=0; i<n; i++)
    a[i]=a[i]*2;
for (i=9; i>=0; i--)
    cout<<a[i]<<endl;

e.

sum=0;
n=6;
k=pow(2,n);
for (i=0;i<k;i++)
    sum=sum+k;
  • 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-27T06:48:12+00:00Added an answer on May 27, 2026 at 6:48 am

    Big O indicates the order of the complexity of your algorithm.

    Basic things :

    • This complexity is measured regarding to the entry size
    • You choose a unit operation (usually affectation or comparison)
    • You count how much time this operation is called
    • A constant term or constant factor is usually ignored when using complexity so if the number of operation is 3*n^3 + 12 it’s simplified to n^3 also marked O(n^3)

    a.) Will just run once, no loop, complexity is trivial here O(1)

    b.) Call n times in the loop: O(n)

    c.) Here we choose to analyze n (because it’s usually the incrementing variable in an algorithm). The number of calls is n – 6 so this is O(n).

    d.) Let’s suppose here that 10 (n) is the size of your array and nine (i) this size minus one. For each value to n, we have to go from 0 to n then n-1 to 0. n * (n-1) operations, technically: O(n * 2) which some people approximate as O(n). Both are called Linear Time, what is different is the slope of the line which BigO doesn’t care about.

    e.) The loop goes from 0 to the pow(2, n), which is 1 to 2^n, summarized as O(2^n)

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

Sidebar

Related Questions

Okay so I need help understanding something. I understand how ? : are used
Need help understanding what I am doing with the syntax here, please help! I
I need help understanding some C++ operator overload statements. The class is declared like
I need some help understanding this bit of code pre { white-space: pre; white-space:
I'm a SQL noob, and I need a little bit of help understanding the
I need some help understanding what's happening here. This code is from a models/log.py
I know this very silly, but can anybody help me in understanding what does
Need some help on understanding how to do this; I'm going to be running
I need a little help with understanding what can I do and cannot in
I need help understanding what the advantage of using an asynch framework is. Suppose

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.