Home > Archive > Java Help > January 2008 > please help with this question
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
please help with this question
|
|
|
| Hi all, Happy new year first of all, to all of you.
i am wondering about what would be the answer of the following:
Is there a heap 'X', sorting 'n' distinct elements (n = 7 for
instance) such that :
- a preorder traversal of 'X' yields the elements of 'X' in sorted
order?
- how about an inorder traversal?
- how about a postorder traversal?
Thanks in advance for any help.
| |
| Eric Sosman 2007-12-30, 7:23 pm |
| Totti wrote:
> Hi all, Happy new year first of all, to all of you.
>
> i am wondering about what would be the answer of the following:
>
> Is there a heap 'X', sorting 'n' distinct elements (n = 7 for
> instance) such that :
>
> - a preorder traversal of 'X' yields the elements of 'X' in sorted
> order?
> - how about an inorder traversal?
> - how about a postorder traversal?
>
> Thanks in advance for any help.
For n = 0, all three traversals produce sorted order.
For n = 1, all three traversals produce sorted order.
Et cetera.
(Your instructor will be especially impressed if you use
the phrase "mathematical induction" to describe this method
of proof. Good luck!)
--
Eric Sosman
esosman@ieee-dot-org.invalid
| |
|
| Eric Sosman wrote:
> Totti wrote:
>
> For n = 0, all three traversals produce sorted order.
>
> For n = 1, all three traversals produce sorted order.
>
> Et cetera.
>
> (Your instructor will be especially impressed if you use
> the phrase "mathematical induction" to describe this method
> of proof. Good luck!)
To the OP: If you're asking for help with your homework, you get honesty
points for saying so up front. No one has respect for an unadorned verbatim
quote of your assignment sheet. If you aren't quoting your homework, you
should say that, too.
Furthermore, simply throwing the question out there for someone else to answer
cheats you of your education, unless, of course, you get a good solid hint
like Eric's and you use it, reason over it, truly grok the process.
Please do report on your progress - in other words, please post your answer so
the rest of us can benefit, too.
--
Lew
| |
|
| no it is not a homework, it is a question in a book i am using to
learn data structres, after each chapter it has some questions, which
i m trying to answer, i got stuck in this one, thats all!
thank you
| |
| Eric Sosman 2007-12-30, 7:23 pm |
| Totti wrote:
> no it is not a homework, it is a question in a book i am using to
> learn data structres, after each chapter it has some questions, which
> i m trying to answer, i got stuck in this one, thats all!
In that case, two suggestions: First, comp.programming
might be a better forum than this one, since the questions
aren't about Java. Second, you'll get a better reception
of you show your work, even if it's incomplete: What ideas
have you had thus far, where have they taken you, what are
you stuck on?
--
Eric Sosman
esosman@ieee-dot-org.invalid
| |
|
| Thank You very much, you were right i must have posted my quote in a
more general topics group.
| |
| Roedy Green 2008-01-08, 8:15 am |
| On Sun, 30 Dec 2007 06:17:53 -0800 (PST), Totti
<saliba.toufic.george@gmail.com> wrote, quoted or indirectly quoted
someone who said :
>
>- a preorder traversal of 'X' yields the elements of 'X' in sorted
>order?
>- how about an inorder traversal?
>- how about a postorder traversal?
Just traverse the tree in either order adding references to an
ArrayList. When you are done it will be sorted in order.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
| |
| apm35@student.open.ac.uk 2008-01-09, 4:38 am |
| On 30 Dec 2007, 15:56, Eric Sosman <esos...@ieee-dot-org.invalid>
wrote:
> Totti wrote:
>
> In that case, two suggestions: First, comp.programming
> might be a better forum than this one, since the questions
> aren't about Java. Second, you'll get a better reception
> of you show your work, even if it's incomplete:
A third point is that the subject should indicate what the post is
about.
-Andrew Marlow
|
|
|
|
|