Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please see below for my question and answer. Please correct me if I'm wrong What is the big-O performance estimate of the following function? int

Please see below for my question and answer. Please correct me if I'm wrong

What is the big-O performance estimate of the following function? int f (n) { int sum = 0; --------------------> Setting sum to "0" with a 1-time operation. So, O(1) for (i = 0; i < n; i = i + 10) --------------------> i = 0 = O(1), i < n = O(n), i = i + 10 = O(1). Since O(1) < O(n), = O(n) sum += i; --------------------> Every loop produces this iteration. So, O(1) return sum; -------------------> O(1) } // end f

Since O(1) < O(n) = total time is O(n)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

How To Build A Million Dollar Database

Authors: Michelle Bergquist

1st Edition

0615246842, 978-0615246840

More Books

Students also viewed these Databases questions

Question

What is the meaning and definition of E-Business?

Answered: 1 week ago