Binary Trees make me sick :(

#1ISDcaptain01Posted 2/14/2013 9:11:45 PM(edited)
Okay so Im reading a book called "Data Structures for Game programmers" and im on the chapter where we study binary trees. Making the tree and understanding it was easy enough.

But making function that automotically travels through it in various orders is brain melting lol. Im dealing with function pointers here, but thats not the problem, the intense recursion is getting to me.

How was your experience with binary trees?
---
lol at --> http://boards.gamefaqs.com/gfaqs/user.php?=89123
#2neoXPosted 2/14/2013 9:29:32 PM
When learning a new algorithm I usually do it in Python real quick and play with recursion and iterative versions until I fully understand them. Then implementing them in other languages is trivial.

:)
---
http://www.goo.gl/en6H3
#3PTP2009Posted 2/14/2013 11:08:52 PM
Being good with recursion involves trusting that the recursive calls will work correctly, even though the code isn't working yet (because you're in the process of writing it). For in-order traversal of trees, for example, you first recursively traverse the left side, then do the current element, then recursively traverse the right side.
#4ISDcaptain01(Topic Creator)Posted 2/14/2013 11:52:39 PM
since Im not a CS student, what do they make you do in the intro data structures class in school?
---
lol at --> http://boards.gamefaqs.com/gfaqs/user.php?=89123
#5OrangeWizardPosted 2/14/2013 11:58:51 PM
From: ISDcaptain01 | #004
since Im not a CS student, what do they make you do in the intro data structures class in school?


lots of push-ups
---
Trolling and making valid arguments are not mutually exclusive things.
#6ISDcaptain01(Topic Creator)Posted 2/15/2013 1:14:10 AM
PTP2009 posted...
Being good with recursion involves trusting that the recursive calls will work correctly, even though the code isn't working yet (because you're in the process of writing it). For in-order traversal of trees, for example, you first recursively traverse the left side, then do the current element, then recursively traverse the right side.


yeah I implemented preorder, postordrr and in order but man are they confusing lol.
I had to sit there, look at my tree graph on paper then trace through it looking at the code. That takes time to sink in.
---
lol at --> http://boards.gamefaqs.com/gfaqs/user.php?=89123
#7ISDcaptain01(Topic Creator)Posted 2/15/2013 1:17:16 AM
OrangeWizard posted...
From: ISDcaptain01 | #004
since Im not a CS student, what do they make you do in the intro data structures class in school?


lots of push-ups


If you mean mental push-ups, then yeah Id agree. No wonder the drop out rate for CS is high
---
lol at --> http://boards.gamefaqs.com/gfaqs/user.php?=89123
#8ReconditePhreakPosted 2/15/2013 6:41:36 AM
If you mean mental push-ups, then yeah Id agree. No wonder the drop out rate for CS is high

No, real push ups to get the blood flowing.
---
Believes the individuals who report to moderators wish they had more control than they do.
#9neoXPosted 2/15/2013 7:47:13 AM
Push ups, pop ups, and peeks. It's a rough routine.
---
http://www.goo.gl/en6H3
#10Skel1Posted 2/15/2013 8:20:52 AM
Loops are just tail recursion. Your mind = blown.
---
http://patrickavella.com/ <> I'm on the intertubes
http://twitter.com/patrickavella <> http://facebook.com/patrick.avella.blog