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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:47:29+00:00 2026-06-08T01:47:29+00:00

The running time should be O(n), this is what I came up with, is

  • 0

The running time should be O(n), this is what I came up with, is it correct? THANKS

for (i = 1 ; i < A[n]; i++)
  A[i] = 0

B[i] = 0;
for i in A[1..n]
  B[i] = B[i] + A[i]
  • 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-08T01:47:31+00:00Added an answer on June 8, 2026 at 1:47 am

    Yes, this is correct. Your solution is the most trivial case of dynamic programming, a technique to greatly speed up algorithms for solutions that can be constructed from solutions from smaller sub-problems.

    Your problem at hand has precisely this property: a solution to B[n] can be constructed in O(1) if you are given a solution to B[n-1], and that is what your algorithm did, for a running time of O(N).

    Solutions like that are very helpful in practice: I once used an algorithm like yours to speed up a piece of start-up code in my program from several minutes to several seconds (it was adding vectors, so it went from O(3) to O(2)).

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

Sidebar

Related Questions

According to my analysis, the running time of this algorithm should be N 2
Running this query takes a long time: SELECT host,ip FROM arecords WHERE ip IN
If I measure the running time of a method, shouldn't it be same if
I'm studying the running time of programs and have come across the Big O
I am wanting to print the running time of my functions. For some reason
I am trying to find the running time O(n) for the block of code
See solution below, I would like some constructive feedback. what is the running time
I am having a hard time running a M2Crypto SSLServer with EXPORT grade ciphers.
I am writting a Python script and I am running out of time. I
I have a silverlight application which users will be running in various time zones

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.