# Thread: a little help with node and BST plz...

1. ## a little help with node and BST plz...

insert
Code:
```So, a binary search tree is basically a data structure created by node?
and what exactly a node does?
does a single node always have 3 boxes? (the key, left and right?)

i have to write a program that will print out a tree...

* Each node should be printed on a separate line;
* the left subtree should be printed after the root;
* The right subtree should be printed before the root;
* The key value should be indented by 2h-2 spaces where h is the height of the node containing it. That is, the root should not be indented, the keys in its subtrees should be intended 2 spaces, the keys in their subtrees 4 spaces, and so on.

For example, the complete tree containing {1,2,3,4,5,6} would be printed like this:

6
5
4
3
2
1

I think i just dont understand the question...
and have a lot of unconcern....e.g., what is the height? aren't they just nodes?

can someone give me some hints on where should i start?
thx!!```

2. Actually in a BST ( binary search tree ) each node will contain an individual values. These are considered as keys.
The properties of the binary search trees are as follows

The left subtree of a node contains only nodes with keys less than the node's key.
The right subtree of a node contains only nodes with keys greater than the node's key.
Both the left and right subtrees must also be binary search trees.

Example
Code:
```                             6
/   \
lst  5     7  rst
/  \
1   8```
lst means left sub tree
rst means right sub tree

3. Yes each node need 3 memory location , one is for store a nodes value then two pointers is point
a another node in the left and one another in the right of its node.

And we can traverser a whole tree ( for printing its value ) by the following way :
o.post order traversal
o.pre-order traversal
o.in-order traversal
I hope that u need to print the tree in post-order traversal

The height of the tree is nothing but a level of the tree
for ex:

Code:
```
1
2          3
4   5     6    7

This tree has height 3```