• Support PF! Buy your school textbooks, materials and every day products Here!

Help with my big oh algorithm analaysis

  • Thread starter mycrafish
  • Start date
  • #1
mycrafish
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++){
System.out.println();
}
}
else{
for(int h = 1; h <= n; h = h*2){
System.out.println();
}
}
}​
 

Answers and Replies

  • #2
39
0
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.
 
  • #3
mycrafish
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
 

Related Threads for: Help with my big oh algorithm analaysis

  • Last Post
Replies
2
Views
684
  • Last Post
Replies
1
Views
1K
  • Last Post
Replies
2
Views
2K
  • Last Post
Replies
2
Views
781
Replies
5
Views
4K
  • Last Post
Replies
0
Views
843
  • Last Post
Replies
2
Views
1K
Top