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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:43:53+00:00 2026-06-05T22:43:53+00:00

To clarify before I begin, this is NOT homework but rather I am studying

  • 0

To clarify before I begin, this is NOT homework but rather I am studying for my exam. I have given solutions for the questions below. I would like some constructive feedback.

Thanks for the feedback for whoever left it in my last question. Below I have given in detail solutions to why i think the answer is so.

Find running time in terms of O(n) notation.

int y=0;
for(int j=1; j*j<=n; j++)// runs from 1->j=sqrt(n) times
    y++; //constant - c

Therefore, run time is c x n^1/2 = O(n^1/2)

Q2.

int b=0;
for(int i=n; i>0; i--) //runs from n->1
    for(int j=0; j<i; j++) // runs from 0 to i
        b=b+5; //constant

for each value of j (1,2...,n) inner loop runs i times constant = ci.
– nc+(n-1)+...+2c+1c = c(n+..+2+1) = cn(n+1)/2 = O(n^2) run time.

Q3.

int y=1;
int j=0;
for(j=1; j<=2n; j=j+2) //runs 2n times, increments by 2
    y=y+i; //constant c

int s=0;
for(i=1; i<=j; i++) // not a nested for loop, therefore runs n times
    s++;  

running time: O(n)

Q4.

int x=0; //constant
for(int i=1; i<=n; i=i*3) //runs log_3 (n) times
{ 
    if(i%2 != 0) // for values above will always be 1

    for(int j=0; j<i; j++) // runs from 0 to log_3(n)
        x++;
}

so we have clog_3(n)xclog_3(n) = O(log_3(n))^2

  • 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-05T22:43:54+00:00Added an answer on June 5, 2026 at 10:43 pm

    Ok, first three are out of doubt (I believe, all are correct).
    But with Q4 there is a problem.

    Your answer is a little bit incorrect. Definitely, the result is not O(log_3(n))^2. The case is in the inner loop, which goes exactly only O(log_3(n)) times. And, not from 0-log_3(n) but from 0-m (where m is obviously correlated to i).

    Assuming all above, I think the right answer is O(mlog3(n)). But if someone think that i was wrong, please correct me.

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

Sidebar

Related Questions

Just need to clarify this one, If I have the below interface public interface
I know this is normally rather stupid, but don't shoot me before reading the
(Before anyone asks, it's not homework.) Say you have 2 Arrays y0 and y1
This topic has been discussed million times before, but let me clarify my needs:
To clarify, I currently have a live app that does not implement in app
Before the "beating a dead horse" comments begin, let me clarify what I am
( Edit : to clarify, my main goal is concurrency, but not necessarily for
EDIT: To answer some questions, this is the revised and still not working code
I don't know if this is the correct website, but you guys have been
before I start I want to clarify that I am not looking for code

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.