COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
traverse the right subtree
|
|
traverse the left subtree
|
|
traverse right subtree and visit the root
|
|
visit the root
|
Detailed explanation-1: -Explanation: In a preorder traversal of a binary tree first is to visit the root, second traverse the left subtree of the tree and third traverse the right subtree of the tree. Explanation: A binary tree is used to sort a list of elements; the inorder traversal will do this automatically.
Detailed explanation-2: -In-order Traversal In this traversal method, the left subtree is visited first, then the root and later the right sub-tree. We should always remember that every node may represent a subtree itself. If a binary tree is traversed in-order, the output will produce sorted key values in an ascending order.
Detailed explanation-3: -Preorder traversal of binary tree is a traversal method, where the root node is visited first, then left subtree and then the right sub tree. Unlike array and linked lists, linear data structures, we have several ways of traversing binary trees due to their hierarchical nature.
Detailed explanation-4: -In a postorder traversal, we recursively do a postorder traversal of the left subtree and the right subtree followed by a visit to the root node.