Question

Find the time complexities O(notion) with cost

int a = 0, i = N;
while (i > 0) {
    a += i;
    i /= 2;

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Find the time complexities O(notion) with cost
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • (10') 6. For each of the following code blocks, write the best (tightest) big-o time complexity...

    (10') 6. For each of the following code blocks, write the best (tightest) big-o time complexity i) for (int i = 0; ǐ < n/2; i++) for (int j -0: ni j++) count++ i) for (int í = 0; i < n; i++) for (int ni j0 - for (int k j k ni kt+) count++ İİİ) for (int í ー 0; i < n; i++) for(int j = n; j > 0; j--) for (int k = 0; k...

  • What is the time complexity of this code? I'm unsure if it is O(log(n)) or O(n)....

    What is the time complexity of this code? I'm unsure if it is O(log(n)) or O(n). I think that the while loop is logn but the for loop that comes after runs the same number of times as the while loop. string toBinary(int num) { string binary = "", temp = ""; while (num != 0) { temp += to_string(num%2); num /= 2; for (int i = temp.size() - 1; i >= 0; i--) { binary += temp[i]; return binary;

  • What is the big o cost of this method? int count = 0; int i =...

    What is the big o cost of this method? int count = 0; int i = 1; while(i < n){ for (j = 1; j < n*n; j *= n) { count++; } i *= 2; } System.out.println(count);

  • Which big-O expression best characterizes the worst case time complexity of the following code? public static...

    Which big-O expression best characterizes the worst case time complexity of the following code? public static int foo(int N) ( int count = 0; int i1; while (i <N) C for (int j = 1; j < N; j=j+2) { count++ i=i+2; return count; A. O(log log N) B. O(log N2) C. O(N log N) D. O(N2)

  • What are the time complexities of these methods? Briefly explain how you counted, for the case...

    What are the time complexities of these methods? Briefly explain how you counted, for the case below. Be careful about power function. You may want to start with a few examples (k=1, k=2, k=3, and figure out the pattern). Explain your answer. void magic(int n, int k) {     for (int i=1; i<=n; i++)     {       int p = pow(i, k);       for (int j=1; j<=p; j++)       {           // printing stuff       }     } }

  • Give a big-Oh characterization, in terms of n,of the running time for each of the following...

    Give a big-Oh characterization, in terms of n,of the running time for each of the following code segments (use the drop-down): - public void func1(int n) { A. @(1). for (int i = n; i > 0; i--) { System.out.println(i); B. follogn). for (int j = 0; j <i; j++) System.out.println(j); c.e(n). System.out.println("Goodbye!"); D.@(nlogn). E.e(n). F.ein). public void func2 (int n) { for (int m=1; m <= n; m++) { system.out.println (m); i = n; while (i >0){ system.out.println(i); i...

  • Can I get some help with this? please and thanks Cost vouw 1. A simple linear...

    Can I get some help with this? please and thanks Cost vouw 1. A simple linear Search algorithm on an unsorted array (30 points) Statements 1 int linearSearch( int [ ]a, int n, int target ) { 2 int i = 0; 3 while (i<n) { if (target == array[i]) return i; i++; 7 } 8 return -1; 9 } 2. The number of statements executed for calculating the average value of a two-dimensional array with n*n elements (30 points)...

  • Please specify Time and Space Complexities in terms of the Big-O notation. for (int j =...

    Please specify Time and Space Complexities in terms of the Big-O notation. for (int j = 1; j < n; j = 2 * j)       sum += j; Question 8 options: O(n^2) O(n log n) O(log n) O(n) O(1)

  • Merge Sort: Time Complexity: O(n log(n)) #include "stdafx.h" #include <iostream> #include <time.h> #include <stdlib.h> using namespace...

    Merge Sort: Time Complexity: O(n log(n)) #include "stdafx.h" #include <iostream> #include <time.h> #include <stdlib.h> using namespace std; void combine(int *a, int low, int high, int mid) {        int i, j, k, c[100000];        i = low;        k = low;        j = mid + 1;        while (i <= mid && j <= high)        {               if (a[i] < a[j])               {                      c[k] = a[i];                      k++;                      i++;               }               else               {                     ...

  • 1. 2. Find the tight bound on the run time for problem 1 and 2 void...

    1. 2. Find the tight bound on the run time for problem 1 and 2 void phone (int n) if (n <147) time +54 else { for (int 0; i< n/2; i++ time++ phone (n/3); for int i = 0; i <13*n; it+) time++ phone (2*n) 3) } void belt (int n) if (n 200) time +=700 else belt (7*n)/10) for (int i-0; i<n; i++) time++ belt (n/5) 0 i <130n; i+-10) for (int i time++ }

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT