PadhaikoAll subjects

Past exam question: 2073 Bhadra (Regular), Q6

Data Structure and Algorithms · 6 marks

Open in the Padhaiko app

Topic: Definition and tree terminologies · Binary trees · Binary search tree

Question

Draw a binary Tree: Preorder F A E K C D H G B In order E A C K F H D B G

Solution

Root and Subtree Partitioning: Root = first element of Preorder = F. Splitting Inorder E A C K | F | H D B G:

Constructed Binary Tree:

               F
            /     \
           A       D
          / \     / \
         E   K   H   G
            /       /
           C       B
Answer:

The binary tree has root F, left subtree A (left E, right K with left C), and right subtree D (left H, right G with left B).

All past exam questions for Data Structure and Algorithms