Re: Binary search tree
- From: "Alf P. Steinbach" <alfps@xxxxxxxx>
- Date: Sun, 25 Nov 2007 12:47:17 +0100
* sarajan82@xxxxxxxxx:
Given a binary search tree and a number n, how can we find the
smallest node of the tree greater than n and the largest node smaller
than n?
For example for the following binary search tree where 5 is root and 4
is the left and 6 the right child, for an input of 5,
4 and 6 will be output:
5
4 6
You posted this question also to [comp.lang.c++].
That's called multi-posting, please don't do it.
Also, please don't post homework questions.
Try instead to do your homework yourself (that's what homework is for, your learning).
Hint: start with an algorithm that finds n if it exists in the tree. Implement that algorithm so that you understand it (if you just read about it and think you understand it, you haven't understood it). When it works, start thinking... ;-)
Cheers, & hth.,
- Alf
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
.
- References:
- Binary search tree
- From: sarajan82
- Binary search tree
- Prev by Date: Binary search tree
- Next by Date: Re: reading network data
- Previous by thread: Binary search tree
- Next by thread: Re: Binary search tree
- Index(es):
Relevant Pages
|