5 votes 5 votes Someone Please Explain this https://gateoverflow.in/2046/gate2014-3-12 DS data-structures + – hacker16 asked Jan 20, 2018 hacker16 2.3k views answer comment Share Follow See all 4 Comments See all 4 4 Comments reply MiNiPanda commented Jan 20, 2018 reply Follow Share The answer is option A right? If it is so then -> As they have said the in order traversal of ternary tree is left-> ROOT->middle->right and for Binary tree left->ROOT->right Here initially you might think whether S is on left or right of Q..but do you see any option starting with something other than S? No. They have taken S 1st so we know it is on the left of Q. And drawing straight down means it's left. So SQP .... Now go to the right subtree of P..R is the root .. We have to take T 1st as it is on the left.. Then Root.. So SQPTR... Then U and W comes in the middle... again same confusion whether W is on left or right.. but as we have seen straight down means left..so W comes before U. SQPTRWU_ left is V. So option A. 2 votes 2 votes hacker16 commented Jan 20, 2018 reply Follow Share by the way what would be the correct answer if we just apply the algorithm without assuming anythin.. i am getting QSPTRUWV, please correct me if i am wrong. @minipanda 0 votes 0 votes MiNiPanda commented Jan 21, 2018 reply Follow Share Yes if you take S and W to be the right child of Q and U respectively then your answer should be correct. 0 votes 0 votes hacker16 commented Jan 21, 2018 reply Follow Share i just assumed both as middle element as per given in the question. 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes what would be the the traversal order in terms of root middle left and right if pre ans post order was asked ? in order traversal is ternary tree is left-> ROOT->middle->right .what will be pre and post for ternary tree? is there any patteen? PRK answered Nov 18, 2019 PRK comment Share Follow See all 0 reply Please log in or register to add a comment.