1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Help with my big oh algorithm analaysis

  1. Mar 17, 2012 #1
    for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
    if (i == j){
    for(int k = 0; k < n*n; k++){
    for(int h = 1; h <= n; h = h*2){
  2. jcsd
  3. Mar 17, 2012 #2
    Any attempt at a solution? Where have you gotten so far? As a small hint, O(n) is the worst case, so look at those loops and think where the most steps can be taken.
  4. Mar 17, 2012 #3
    i know the answer is n3 + n2log2n - nlog2n but i have no idea how to get this far
    I know the loops runs n^2 times at least but im not sure how to do the if statements
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook