• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 669
  • Last Modified:

Binary Trees in Pascal

Can someone write a binary tree program in Pascal so that I don't have to please?  It has to be impressive so it makes me look good.
0
BIGAL
Asked:
BIGAL
  • 8
  • 3
  • 2
  • +5
1 Solution
 
kellyjjCommented:
Talk about honesty!  This site isn't for people to HOMEWORK for others.  You should try to do this yourself and then ask for help on the parts you are having problems with.  

Otherwise, find someone local to you who you can pay.  
0
 
gikamCommented:
kelly's right
0
 
InteqamCommented:
its easy , try it.

0
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

 
jack_p50Commented:
Give me your e-mail, and i send it to you - i have a couple of this.
0
 
scrapdogCommented:
In order to grasp the concept of binary trees, you have to do it yourself.  It is one of the most complex data structures.
0
 
MotazCommented:
The most interesting thing in programming is to solv your porblems by your self.

Data structure is the most interesting field in computer science specially when we understand it.

Motaz from Sudan.
0
 
daittCommented:
Just accept jack_p50's answer and get source code. No matter what all others tell you, if you just need programs for your work (you have no time, not interesting in data structure but have to work with it, I suppose). But if you want to understand algorithms, you have to do it yourself, without or with a little help from others.
Anyway, I have tell you that I'm totally sad here.
0
 
scrapdogCommented:
Daitt: it is clearly homework.
0
 
viktornetCommented:
Hey, what's a binary tree and what it is needed for??

Vik
0
 
scrapdogCommented:
It is a data structure like a linked list, except each node has two links.  There are many uses for binary trees...3-d games use them, mathematical parsers uses them...
0
 
viktornetCommented:
Ya, Kevin....Can you show me a simple example.... If you decide to give me an example, you could do it by mail ;-)

Cheers,
Viktor
0
 
scrapdogCommented:
Here is a very simple way of coding a binary tree:

type
  PNode = ^TNode;
  TNode = record
            Value :Integer;
            Left  :PNode;
            Right :PNode;      
          end;

var a,b,c,d,e,f,g,h :PNode;
begin
  New(b);
  New(c);
  New(a);
  a^.Left := b;
  a^.Right := c;
  New(d);
  New(e);
  d^.Left := a;
  d^.Right := e;
  New(f);
  e^.Left := f;
  New(g);
  b^.Left := g;
  New(h);
  c^.Right := h;
  ...
  ...
end.

This would create a tree that looks like this:
________________D
_______________/_\  
______________/___\
_____________A_____E
____________/_\___/
___________B___C_F
__________/_____\
_________G_______H

I used the underscores to make sure everything lines up OK.        

0
 
scrapdogCommented:
Vik:   that still looks screwed up, even though I used underscores.  Copy and paste that into the "Have a comment to..." box to look at it in the Courier font.
0
 
viktornetCommented:
I just pasted it in Notepad, and it looks very pretty ;-)

I've seen this kinda stuff somewhere... Is that how databases are done??? Kinda???

btw- Thanks for the example :-)

Vik
0
 
scrapdogCommented:
Databases don't *normally* use trees, but they could.
0
 
scrapdogCommented:
Here's somewhat of a tutorial on binary trees:

http://www.geocities.com/SiliconValley/Way/8593/javadata.html

It's in java however.
0
 
scrapdogCommented:
0
 
jack_p50Commented:
Trees can be used for expression evaluators
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 8
  • 3
  • 2
  • +5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now