How to find empty nodes in binary tree?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

askbapi
Forum Newbie
Posts: 10
Joined: Fri Dec 04, 2009 11:24 pm
Location: India

How to find empty nodes in binary tree?

Post by askbapi »

I want to find all empty nodes present in a binary tree. The tree is stored in DB in a table with following fields : NodeName, ParentID, ParentSide.

Example :
A
/ \
B empty node
/ \
B1 empty node
/ \
empty node empty node

How can i find all this nodes?

Help please.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: How to find empty nodes in binary tree?

Post by VladSun »

What have you tried so far?
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Re: How to find empty nodes in binary tree?

Post by Jenk »

We're not prepared to do your coursework for you.
askbapi
Forum Newbie
Posts: 10
Joined: Fri Dec 04, 2009 11:24 pm
Location: India

Re: How to find empty nodes in binary tree?

Post by askbapi »

Jenk wrote:We're not prepared to do your coursework for you.
No, you don't have to. I have solved it myself.

Anyway thank for your reply!
:offtopic:
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: How to find empty nodes in binary tree?

Post by alex.barylski »

No, you don't have to. I have solved it myself.
So you admit your guilty of submitting course material on a forum to have someone else hopefully solve it? I'm not sure if thats intelligence or just lazy. :)
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Re: How to find empty nodes in binary tree?

Post by Jenk »

"Solved it" by copying an answer from another forum no less :lol:
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: How to find empty nodes in binary tree?

Post by alex.barylski »

Probably, sad but true. :)
askbapi
Forum Newbie
Posts: 10
Joined: Fri Dec 04, 2009 11:24 pm
Location: India

Re: How to find empty nodes in binary tree?

Post by askbapi »

PCSpectra wrote:
No, you don't have to. I have solved it myself.
So you admit your guilty of submitting course material on a forum to have someone else hopefully solve it? I'm not sure if thats intelligence or just lazy. :)
After all the forum are made to help each other.

But genus like u, can only see the negative part, where most the people are lazy.

> "someone else hopefully solve it" - someone else is not U.
If u are a programmer, than u must have gone thru a phase in programming, when u feel that can't solve the problem and leave it or ask for help from other. After some time, a new idea pop up ur mind and that it. It is solved.
askbapi
Forum Newbie
Posts: 10
Joined: Fri Dec 04, 2009 11:24 pm
Location: India

Re: How to find empty nodes in binary tree?

Post by askbapi »

Jenk wrote:"Solved it" by copying an answer from another forum no less :lol:
U must a great programmer who don't take any help from other and You solve ur programing problems all by urself. :lol:
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: How to find empty nodes in binary tree?

Post by VladSun »

askbapi wrote:
Jenk wrote:"Solved it" by copying an answer from another forum no less :lol:
U must a great programmer who don't take any help from other and You solve ur programing problems all by urself. :lol:
While he is a great programmer, he is also a great "fisherman" :P
Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.
There are 10 types of people in this world, those who understand binary and those who don't
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: How to find empty nodes in binary tree?

Post by alex.barylski »

U must a great programmer who don't take any help from other and You solve ur programing problems all by urself
We have all seen our fare share of college students asking for answers to problems on these boards and others, nothing new there. The way you asked the question, indicated you were doing the same thing. Had you put a little effort into the question, like explaining what you had done hitherto, you might have received a different reply. You probalby wouldnèt have got a reply at all actually.

1. That topic is not trivial
2. That topic is not interesting to most developers

Cheers,
Alex
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Re: How to find empty nodes in binary tree?

Post by Jenk »

askbapi wrote:
Jenk wrote:"Solved it" by copying an answer from another forum no less :lol:
U must a great programmer who don't take any help from other and You solve ur programing problems all by urself. :lol:
This thread was not asking for help, it was asking for the answer to be given for you, without you even trying nor learning from it.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: How to find empty nodes in binary tree?

Post by VladSun »

PCSpectra wrote:1. That topic is not trivial
2. That topic is not interesting to most developers
:offtopic:

That's what interesting about this thread - I feel like I'll refuse to answer "Headers already sent ... bla-bla"-like questions, but I'm willing to answer questions like the one in this thread. I see it happens to all "advanced" members in this forum - they do refuse to answer the "usual-suspects" questions, but will answer "trivial" and not so "usual" questions.
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Re: How to find empty nodes in binary tree?

Post by Jenk »

My reasons for not answering this thread's question should be clear, but in case they are not:

The OP has not made any effort to answer this themselves yet. We (I) like to help people to learn, not provide an answer for their exam paper for them to copy.

This is such an amazingly common question in exams/course work. There is even an entire Wikipedia page dedicated to it, furhter demonstrating that the OP hasn't even bothered to interpret the problem, merely scan the web for a copy/paste answer.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: How to find empty nodes in binary tree?

Post by Benjamin »

So how about posting your solution?
Post Reply