10 10 votes A binary tree has:$1000$ nodes in the left subtree $100$ nodes in the right subtreeHow many nodes are processed before the root in preorder, inorder, and postorder traversal respectively?$0, 1000, 1100$ $1000, 0, 1100$ $1100, 1000, 0$ $0, 1100, 1000$ Data Structures goclasses goclasses-da-dpp goclasses-da-dpp-day-235 goclasses-cs-dpp goclasses-cs-dpp-day-333 data-structures python-&-dsa goclasses-python-&-dsa-practice-questions goclasses-ds-practice-questions binary-tree + – GO Classes 359 views answer comment Share Follow Print See 1 comment 1 1 comment reply Akash_Mishra commented Aug 22 reply Follow flag We know that in preorder, the root node comes first from the left end: root, left subtree elements, right subtree elements. That's why, before the root element in preorder, it is 0.And we know that in postorder, the root node comes last from the left end: left subtree elements, right subtree elements, root. That's why, before the root element in preorder, it is left subtree elements + right subtree elements ie 1100.And we know that in inorder, the root node comes in the middle from the both end: left subtree elements, root, right subtree elements. That's why, before the root element in inorder, it is the left subtree elements , i.e., 1100. 0 0 replyShare Please log in or register to add a comment.
0 0 votes The tree has:$1000$ nodes in the left subtree$100$ nodes in the right subtreeIn preorder traversal, order is:Root, Left, RightSo, the root is processed first. Number of nodes before root is:$0$In inorder traversal, order is:Left, Root, RightSo, all nodes in the left subtree are processed before the root. Number of nodes before root is:$1000$In postorder traversal, order is:Left, Right, RootSo, all nodes in the left and right subtrees are processed before the root.Total nodes before root:$1000 + 100 = 1100$Therefore, the required values are:$\boxed{0, 1000, 1100}$ GO Classes answered Jul 28 GO Classes comment Share Follow 0 reply Please log in or register to add a comment.