Big O Notion Help for project
hello guys i am in 3th years of studying in uni,i am toke this example as a heading of my project and need answers for it with all thanks, i am software eng
first part: O(g(n)) for this:
(n + 3 )(n + n2+ 4)
5logn+3n+1000
Logn+ 100 +1/ n2
100n2+ ½ n3 +5
(3n2 + 4)3
second part : number of operation of this
1)
if (condition)
{ cout<<”Hello”<<endl; }
else
{
for (i = 0; i < N; i++) {
cout<<”Hi”<<endl;
}
}
2)for (i = 0; i < N; i++) {
for (j = i+1; j < N; j++) {
sequence of statements
}
}
3)for (i = 0; i < 2*N; i++) {
sequence of statements
}
for (j = 0; j < M-1; j++) {
sequence of statements
}
4)
void fun(int k)
{
for (i = 0; i < N; i++) {
sequence of statements
}
}
void main(){
//declaration statements
for (i = 0; i < N; i++) {
fun(i);
}
}
Re: Big O Notion Help for project
Give us your answers first and then we can help you out.
Re: Big O Notion Help for project
Re: Big O Notion Help for project
this my answer for first part:
first: n3
sec:n
third:n2
forth:n2
five:n6
Re: Big O Notion Help for project
Quote:
Originally Posted by
javaguys
this my answer for first part:
Your notation is somewhat ambiguous since you don't separate multiplication and power-of clearly.
Still the Ordo complexity of an expression is determined by the fastest growing term when N approaches infinity. In my view you've got it wrong in the third and fourth example. They should be O(logN) and O(N^3) respectively.
Re: Big O Notion Help for project
thanks bro,i want o(n) of it, as i said above for:
1)
(n + 3 )(n + n^2+ 4)
2)5logn+3n+1000
3)Logn+ 100 +1/ n^2
4)100n^2+ ½ n^3 +5
5)(3n^2 + 4)^3
still wait answers
Re: Big O Notion Help for project
Quote:
Originally Posted by
javaguys
still wait answers
I think you got it all right except for 3 and 4 (for which I gave suggestions in my previous reply).
Re: Big O Notion Help for project
O(logN) and O(N^3) for third and fourth this is true answer?
hmmm, what about part B bro?
Re: Big O Notion Help for project
Quote:
Originally Posted by
javaguys
O(logN) and O(N^3) for third and fourth this is true answer?
Yes, I would say so. The Ordo complexity is determined by the term that grows the fastest asymptotically. And that's the term you picked in all cases except in 3 and 4. In 3 it's log(n) and in 4 it's n^3 so these will determine the complexity.
But don't take what I say at face value. After having studied software engineering for 3 years at a university you should know this better than I do.
Quote:
hmmm, what about part B bro?
Yes what about it? If you suggest something with a motivation I'll tell you what I think.
Re: Big O Notion Help for project
i know how to find number of operation, but i need to know big o of this codes in part b, i want to tell you that just first material talking about algorithms so sorry if i need just Little help