berkc
berkc

Reputation: 525

Tree Traversals

I know how to write in-order traversal code for Binary Search Tree. I just wonder, will in-order traversal code for AVL Tree and Red-Black Tree be same as BST code? Since all 3 has the same rules, smaller to left, larger to right, same code should work. Does anybody have any idea ?

Upvotes: 1

Views: 80

Answers (2)

Saif
Saif

Reputation: 7042

The insertion/update/balancing process would be different for different types of tree.

But the traversal code (at least the procedure) will be almost same for all kind of tree.

Upvotes: 1

Lolo
Lolo

Reputation: 4347

Since AVL and Red Black Trees are self-balancing Binary Search Trees, they are still BSTs, therefore the in-order traversal code should be the same or all three of them.

Upvotes: 2

Related Questions