954,535 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

binary tree traversal ..

can anyone tell me the code for inorder traversal of binary tree non recursively and using a constant memory ...??

joshilay
Light Poster
31 posts since Jul 2006
Reputation Points: 10
Solved Threads: 0
 

Is this for c or c++?

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 
Is this for c or c++?


u can write in anyone c or c++ ..whichever is comfortable to you ..

joshilay
Light Poster
31 posts since Jul 2006
Reputation Points: 10
Solved Threads: 0
 
u can write in anyone c or c++ ..whichever is comfortable to you ..

Remember one thing. Nobody writes code for you. If you have a problem with code you have written, post it, and someone may point out the errors for you. Other than that, asking someone to write code in C/C++ whichever is comfortable will be a waste of time in your part.

WolfPack
Postaholic
Moderator
2,051 posts since Jun 2005
Reputation Points: 572
Solved Threads: 115
 
Remember one thing. Nobody writes code for you. If you have a problem with code you have written, post it, and someone may point out the errors for you. Other than that, asking someone to write code in C/C++ whichever is comfortable will be a waste of time in your part.



whos so ever you are ..i have asked a qusetion ..its upto others whether they want to write code or not ...who are you to decide this ??

joshilay
Light Poster
31 posts since Jul 2006
Reputation Points: 10
Solved Threads: 0
 

Wait and see.

WolfPack
Postaholic
Moderator
2,051 posts since Jun 2005
Reputation Points: 572
Solved Threads: 115
 

>who are you to decide this ??
The forum rules decided this and the community enforces it. If you have a problem with that, leave.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

its good that forum is abide by some rules and regulations to maintain legacy ..but i have seen in many others threads people have asked to write codes even some people have asked to write there code give in there assignments ...so this come as shock for me when i get a reply like this from wolfpack..if anyone can write code its good ..but he/she can also make me understand the logic behind the that algorithm...

joshilay
Light Poster
31 posts since Jul 2006
Reputation Points: 10
Solved Threads: 0
 

>but i have seen in many others threads people have asked to write
>codes even some people have asked to write there code give in there assignments
And in how many of those threads did those people get flamed for it? I'm willing to bet pretty much all of them.

>but he/she can also make me understand the logic behind the that algorithm...
Yes, but you asked for code. That suggests that you're making no attempt to understand the problem or solve it for yourself. A better way to post would be to ask for help understanding the problem, while specifying things you've already tried. At least that way we know you've tried to think for yourself.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

Yeah that's right. If you can post here you're on the interweb thingy so go to that google thingy and search 'binary tree' and you get links like this:

http://www.cprogramming.com/tutorial/lesson18.html

Read and have a go, then when you get stuck come back here, post what you got and we all help.

hollystyles
Veteran Poster
1,182 posts since Feb 2005
Reputation Points: 262
Solved Threads: 68
 

I can just explain you how to code on code it in any language of your desire

Algorithm Suggest: -
i) visit the left Subtree
ii) visit the Node
iii) visit the right Subtree

You are interested in making the Non Recursive version of the above traversal. You can make it easily... if you know how recursion attempts the problem, infact recusion is using the implicit stack. So you might use an explicit stack to tackle the same problem :). My Suggessions are first try to solve it by hand then you'll get the idea what infact you are doing then try to code the logic.
Give me your code of recursive Version I'll give you mine (non recursive version :d).......

Hope you get the basic idea........

Laiq Ahmed
Junior Poster
148 posts since Jun 2006
Reputation Points: 113
Solved Threads: 20
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You