Explore BrainMass

Explore BrainMass

    converting ternary to binary

    Not what you're looking for? Search our solutions OR ask your own Custom question.

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    Write the pseudocode for a recursive function TERNARY TO BINARY, that will convert a ternary tree into a binary search tree.

    © BrainMass Inc. brainmass.com May 24, 2023, 1:25 pm ad1c9bdddf

    Solution Preview

    I recommend reading the attached file; it's the same as below but with nicer formatting :-)


    Your problem is to write a psuedocode algorithm which will take in a ternary search tree and convert it into a binary search tree.

    Recall that a ternary search tree is just a binary search tree where each node has an extra child. I will assume for this problem that in your binary search tree, a matching node becomes the right child; you can easily modify the algorithm if your teacher prefers it to be the left child.

    Let's start with just the most basic psuedocode:

    set binary_node_1 = ternary_node_1

    Solution Summary

    The expert writes pseudocodes for a recursive function. The expert converts a ternary tree into a binary search tree.