Do you know implementation of traversal of a binary tree?
Submitted by: AdministratorBinary tree traversal is a process of visiting each and every node of the tree. The two fundamental binary tree traversals are ‘depth-first' and ‘breadth-first'.
The depth-first traversal are classified into 3 types, namely, pre-order, in-order and post-order.
Pre-order: Pre-order traversal involves visiting the root node first, then traversing the left sub tree and finally the right sub tree.
In-order: In-order traversal involves visiting the left sub tree first, then visiting the root node and finally the right sub tree.
Post-order: Post-order traversal involves visiting the left sub tree first, then visiting the right sub tree and finally visiting the root node.
The breadth-first traversal is the ‘level-order traversal'. The level-order traversal does not follow the branches of the tree. The first-in first-out queue is needed to traversal in level-order traversal.
Submitted by: Administrator
The depth-first traversal are classified into 3 types, namely, pre-order, in-order and post-order.
Pre-order: Pre-order traversal involves visiting the root node first, then traversing the left sub tree and finally the right sub tree.
In-order: In-order traversal involves visiting the left sub tree first, then visiting the root node and finally the right sub tree.
Post-order: Post-order traversal involves visiting the left sub tree first, then visiting the right sub tree and finally visiting the root node.
The breadth-first traversal is the ‘level-order traversal'. The level-order traversal does not follow the branches of the tree. The first-in first-out queue is needed to traversal in level-order traversal.
Submitted by: Administrator
Read Online Data Structures Trees Job Interview Questions And Answers
Top Data Structures Trees Questions
☺ | Explain red-black trees? |
☺ | How to find the depth of a binary tree? |
☺ | What is threaded binary tree. Explain its common uses? |
☺ | Do you know implementation of traversal of a binary tree? |
☺ | Explain B+ tree? Explain its uses? |
Top Coding/Programming Categories
☺ | Python Interview Questions. |
☺ | OOP Interview Questions. |
☺ | Software engineering Interview Questions. |
☺ | PHP Interview Questions. |
☺ | VBA (Visual Basic for Applications) Interview Questions. |