Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Application Programming

Reply
 
LinkBack Thread Tools
Old 03-12-09   #1 (permalink)
Audiophile
 
Gnarly's Avatar
 
intel nvidia

Join Date: Oct 2004
Location: Missouri
Posts: 2,198

Rep: 113 Gnarly is acknowledged by manyGnarly is acknowledged by many
Unique Rep: 91
FAQs Submitted: 2
Trader Rating: 4
Default constant, linear, or quadratic time? generic question.

I have to analyse functions that deal with trees for my C++ class.

I understand the concept of of log, constant, linear, quadratic functions, and Big-O notation, but not so much when it comes to trees.

There are three functions, function 3 calls 2, 2 calls 1, and 1 prints out data. To traverse this tree (each node can have unlimited number of branches, but in this case they have 4), the 3rd function is called, nested in its for loop function 2 is called, nested in 2's for loop function 1 is called.

Loops 3 and 2 depend on the number of children while 3 depends on how many values are stored in each member. What is the big O notation for the functions?

I initially thought quadratic because of the nested loops, but logically it seems as the tree gets larger, it takes constant time to traverse it and print all of it's data out.

Your thoughts?

I can try to reword this if necessary.

Thanks,

Wyatt

(ps, I might have different questions later, so check back if these types of problems are fun for ya.)
__________________
System: Promise of Stress
CPU
Q9450
Motherboard
GIGABYTE GA-EP35-DS3L P35
Memory
4x2gb G.Skill DDR2 800
Graphics Card
evga gtx 260 192
Hard Drive
640gb WD + 750gb Samsung
Sound Card
Flashed Chaintech AV710 for optical out
Power Supply
Corsair HX520W
Case
Coolermaster CM690
CPU cooling
lapped Tuniq Tower
OS
Vista Business x64
Monitor
24" Samsung
Gnarly is offline   Reply With Quote
Old 03-13-09   #2 (permalink)
Another World
 
TFL Replica's Avatar
 
intel nvidia

Join Date: Oct 2008
Location: Last place you'd wanna be
Posts: 3,178

Rep: 312 TFL Replica is a proven memberTFL Replica is a proven memberTFL Replica is a proven memberTFL Replica is a proven member
Unique Rep: 242
Hardware Reviews: 1
Trader Rating: 0
Default

You need to reword the part where you explained the functions (and maybe post the code as well). What is function 2 doing?

There's no way it's constant though. A larger tree does not take the same time to traverse as a smaller one. That's before even taking into account the other 2 functions you have thus far only vaguely defined.
__________________
The Official Asus Republic Of Gamers Series Motherboard Club
ß₤ứə Çřёώ
Newcomers read this:What is REP?



System: Light Armor
CPU
Intel Core 2 E8400 C0 @ 4GHz - 1.376v
Motherboard
ASUS Rampage Formula X48
Memory
2x2GB G.Skill PI Black PC2 6400
Graphics Card
Inno3D GTX 275 OC
Hard Drive
3xMaxtor + 2xWD = 2.91TB
Sound Card
X-FI Fatal1ty Xtreme Gamer Professional
Power Supply
PC Power and Cooling Silencer 750w
Case
Thermaltake Armor VA8003SWA
CPU cooling
Zerotherm Zen FZ120 - Stock Fan
GPU cooling
Stock
OS
XP Pro SP3 / 7 x64 Ultimate / Distro Hopping
Monitor
LG W2284F
TFL Replica is offline Overclocked Account   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -5. The time now is 06:17 PM.


Overclock.net is a Carbon Neutral Site Creative Commons License

Terms of Service / Forum Rules | Privacy Policy | DMCA Info | Advertising | Become an Official Vendor
Copyright © 2009 Shogun Interactive Development. Most rights reserved.
Page generated in 0.10623 seconds with 8 queries