Explore BrainMass

converting ternary to binary

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 July 20, 2018, 7:02 am 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.