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

Member Avatar for iamthwee

Is this for c or c++?

Is this for c or c++?

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

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.

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 ??

Wait and see.

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

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...

>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.

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.

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........

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.