# Binary trees , Representation, Traversals - DSA Lab 10

Software and s/w Development

Nov 10, 2012 (5 years and 7 months ago)

318 views

DSA Lab 10

Binary trees

Representation

Traversals

What high school did you finish

Where are you from

Do you want to help promote the faculty?

What do you need (banners, flyers etc)?

What are trees?

a tree data structure in which each node
has at most two child nodes, usually
distinguished as "left" and "right".

Root node

Parent node

Leaf node

Experimental lab

Try to see if the C/C++ programming
langauge is not letting you
understanding the data structures.

For this lab, we will use java (from PL).

You will find Netbeans on the memory
stick.

What do we need to model?

Node class

Tree class

The Node class

The Tree class

Traversals

Consider the following binary tree:

Preorder (root, left, right)

Inorder (left, root, right);

Postorder (left, right, root)

Traversals

Consider the following binary tree:

Preorder (root, left, right)

F, B, A, D, C, E, G, I, H

Inorder (left, root, right);

A, B, C, D, E, F, G, H, I

Postorder (left, right, root)

A, C, E, D, B, H, I, G, F

Preorder (root, left, right)

F, B, A, D, C, E, G, I, H

Inorder (left, root, right);

A, B, C, D, E, F, G, H, I

Postorder (left, right, root)

A, C, E, D, B, H, I, G, F

Inorder traversal

Testing the solution

Homework

Finish all traversal implementations.

Extend the tree structure to support
deletes (by node value).