Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. What is the time complexity of the algorithm below? void algorithm1 (int n) { int x = 0; for (int i = 0; i

1. What is the time complexity of the algorithm below? void algorithm1 (int n) { int x = 0; for (int i = 0; i < n; ++i) for (int j = i; j < n; ++j) for (int k = 1; k < 100; ++k) x += 1; } 2. What is the time complexity of the algorithm below? void algorithm ( int n ) { int i, j, k; int m = 0; for ( i = 0; i < n; i++) { for ( j = 1; j < n; j += 2) { for ( k = 1; k < n; k *= 2) { m += k; } } } } 3.

What is the time complexity of the algorithm below?

int algorithm (int n) { if (n == 1) return 1; else return 2 * algorithm (n/2); } I think the answers are O(n^3), O(n^3) and O(log 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

Database Security XI Status And Prospects

Authors: T.Y. Lin, Shelly Qian

1st Edition

0412820900, 978-0412820908

More Books

Students also viewed these Databases questions