Discussion
The set T represents various traversals over binary tree. The set S represents the order of visiting nodes during a traversal.
| T | S |
|---|---|
| I: Inorder | L: left subtree, node, right subtree |
| II: Preorder | M: node, left subtree, right subtree |
| III: Postorder | N: left subtree, right subtree, node |
Which one of the following is the correct match from T to S ?
Answer: A
The correct match is I - L, II - M, III - N.
The names say where the node is visited relative to its subtrees:
- Inorder: left subtree, node, right subtree (L). For a binary search tree this lists the keys in sorted order.
- Preorder: node first, then left and right subtrees (M).
- Postorder: left and right subtrees first, node last (N).
Every other option assigns at least one traversal the wrong position for the node: matching inorder to 'node, left, right' or postorder to 'left, node, right' confuses the prefixes pre, in and post, which refer exactly to that position.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development