Q:

How to implement a binary tree in matlab

Can somebody please help me with implementing a binary tree in matlab? Can we do it the same way we implement the same in C/C++ using pointers? I happen to read a question related to the same and the solution too using 'struct' but that code executes 'n' number of times given that n is predefined. But I deal with a problem where the tree has to be formed dynamically. ie,
1.Take a node
    1.1 Do some processing 
    1.2 If the resulting two answers satisfy the condition, they are added as the left and     right children
    1.3 Continue the process till the condition is false.
 2.Trace back and move to the next node.

Thanks in advance.

A:

This may only partly answer your question. To get anywhere close to the mechanisms of pointers in C/C++, you might start by checking the object oriented features of MATLAB. Namely the ability to create handle classes.
There is a fully documented example for the implementation of a doubly-linked list, which comes pretty close to a binary tree.

