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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:16:16+00:00 2026-06-01T18:16:16+00:00

if x: for i in range(a): for z in range(a): for k in range(z):

  • 0
if x:
    for i in range(a):
       for z in range(a):
          for k in range(z):
             for p in range(i):
                c = (i * z) + (k * p)
else:
    for i in range(a):
       for z in range(a):
          for k in range(z):
              c = (i * z) + (k * p)

Would this be O(n^4)? Also, how many multiplications would occur?

EDIT: updated the code. Also, since the lower bound captures the max number of steps a valid input will force, wouldn’t big omega be n^4 as well?

  • 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-01T18:16:18+00:00Added an answer on June 1, 2026 at 6:16 pm

    Yes, the complexity is still O(n^4). To make things simple, here is the trick to rearrange your code

    for i in range(a):
       for p in range(i):
           f(i, p)
    

    where f(i, p) is

    for z in range(a):
        for k in range(z):
            c = (i * z) + (k * p)
    

    In the first part, f(i, p) has been executed for O(n^2/2) up to the largest order (because of the summation sum_i (i^2), do the math yourself). Similarly, the f(i, p) has the complexity of f(i, p) which is again equal to O(n^2/2).

    So the combined resulting order is O(n^4/4). and there is two multiplications for each operation, so number of multiplication is O(n^4/2)

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

Sidebar

Related Questions

I have create name range on sheet A so I need to use this
I'm building a range between two numbers (floats) and I'd like this range to
import string ## This part of the code initializes the program by recieving inputs
I am trying to translate the VBA code found in this link into IronPython.
EDIT: I ran the python profiler and the two most time-consuming things (this is
I would like to write a JavaScript function that validates a zip code, by
Can anyone tell me why this code is returning undefined . I was hoping
Given a date range how to calculate the number of weekends partially or wholly
We can use solr range query like: http://localhost:8983/solr/select?q=queryStr&fq=x:[10 TO 100] AND y:[20 TO 300]
I've created a Range type: public class Range<T> where T : IComparable<T> { public

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.