|
|
#21 (permalink) | |
|
TestMagic Guru
![]() ![]() ![]() ![]() Join Date: Jul 2003
Location: Brazil
Posts: 1,360
![]() |
Quote:
function b(n) { if (n <= 2) return n; return b(n-1) + 2*b(n-2); // not a } Definitely O(2^(n-1)), as calculating a few will tell. Run time O(n). Look at AlbaLed's explanation and mine for the runtime. It is definitely not linear.. I ran a program and after 50, my pentium IV at work was crawling! Why isn't it O(3^N)? |
|
|
|
|
|
|
#23 (permalink) | |
|
TestMagic Guru-in-Training
![]() ![]() ![]() Join Date: Oct 2003
Location: USA
Posts: 508
![]() |
Quote:
Hm. Is it true that computing the left hand subtree is twice as expensive as the right hand? I'm not so good with trees. |
|
|
|
|
|
|
#24 (permalink) | ||
|
TestMagic Guru-in-Training
![]() ![]() ![]() Join Date: Oct 2003
Location: USA
Posts: 508
![]() |
Quote:
http://www.TestMagic.com/forum/topic.asp?TOPIC_ID=8613 |
||
|
|
|
|
|
#25 (permalink) | |
|
TestMagic Guru-in-Training
![]() ![]() ![]() Join Date: Oct 2003
Location: USA
Posts: 508
![]() |
Quote:
So you're both right! |
|
|
|
|
|
|
#26 (permalink) |
|
TestMagic Guru
![]() ![]() ![]() ![]() Join Date: Jul 2003
Location: Brazil
Posts: 1,360
![]() |
Hehehe... don't worry... I'll be the one with 630 and you'll get around 890 or so... !! I do VERY poorly in timed exams... somehow I get nervous and start trembling, etc. I never liked it. Millions things passed through my mind. Hard to focus!! Anyway... We'll all try our best.
Wood |
|
|
|
|
|
#27 (permalink) |
|
TestMagic Guru-in-Training
![]() ![]() ![]() Join Date: Oct 2003
Location: Albania
Posts: 534
![]() |
In my opinion as long as you get the idea, ie. log(n), c^n, the base of the log or the c in the exponential will not matter, because you're describing a big OH notation, not exact. So as long as you get whether it is linear, log, poly or expo I think it does not matter anymore. If asked for exact that's when constants come to play
|
|
|
|
|
|
#28 (permalink) |
|
TestMagic Guru-in-Training
![]() ![]() ![]() Join Date: Oct 2003
Location: USA
Posts: 508
![]() |
Phehw. Last two.
function g(n) { if (n <= 10) return n; return g(n-1) + f(n-2) + e(n-3); } Well, if we didn't have the f or e, we'd just have O(n). The f(n) was n! or 0, depending on whether you guessed that I had a typo. e(n) was (lgn)!, in case you didn't realize that, based on my comment above. If you take the correct value for f(n), I guess that g(n) must be a little bigger than n!, but not bigger than n*n!, so O( ((n+1)!) ) will work here. I don't see a quick way to get a tighter bound. function h(n) { if (n <= 10) return n; return 2*h(n/2) + n*lgn; } Let a = 2, b = 2, r = log(a base b) = 1. n*lg n = Big Omega (n^r). It also satisfies a*(n/b)*(lg n/b) < c*n*lgn for some c < 1. Master's Theorem applies. So the answer is O(n*lgn) |
|
|
|
|
|
#29 (permalink) |
|
TestMagic Guru-in-Training
![]() ![]() ![]() Join Date: Oct 2003
Location: Albania
Posts: 534
![]() |
wood, with all this practice we're getting we probably talk about this stuff in our sleep. Don't worry dude, we're doing the best all of us can, smth that by ourselves we could have never done, so believe in the power of team, and get in the exam concious that all of us are with you and kick butt, after you;re done share a drink with us :drunk:
|
|
|
|
|
|
#30 (permalink) | |
|
TestMagic Guru-in-Training
![]() ![]() ![]() Join Date: Oct 2003
Location: USA
Posts: 508
![]() |
Quote:
I used to tremble, too, and sweat a lot. Now it's not so bad. One big problem I have right now is that my mind wants to move onto the next problem as soon as I think I understand the answer to the current problem. At that moment, I start filling in the bubble without really thinking about what I'm doing, and I sometimes fill in the wrong bubble!!!!! SO the past few weeks, I've been practicing filling in bubbles as I do practice problems. It seems to be helping. |
|
|
|
|
Contact TestMagic TestMagic Forums Archive Privacy Statement
TestMagic Locations
Legal
Privacy
SEO by vBSEO 3.2.0
Copyright © 2009 TestMagic
Ad Management by RedTyger