Path: news.mathworks.com!not-for-mail
From: "Davis " <dsentman@gi.alaska.edu>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Tree data structure in MatLab
Date: Sat, 16 Jan 2010 23:27:02 +0000 (UTC)
Organization: University of Alaska
Lines: 14
Message-ID: <hiti06$qm1$1@fred.mathworks.com>
References: <hckg5o$8t6$1@fred.mathworks.com>
Reply-To: "Davis " <dsentman@gi.alaska.edu>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1263684422 27329 172.30.248.35 (16 Jan 2010 23:27:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 16 Jan 2010 23:27:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 25668
Xref: news.mathworks.com comp.soft-sys.matlab:599371


"Yersinio Jimenez" <yersinioj@hotmail.com> wrote in message <hckg5o$8t6$1@fred.mathworks.com>...
> Hi every guys.
> 
> Does any one know if there is some tree like data structure in MatLab?
> 
> The questions is because some algorithms are more clear if you think in terms of tree data structure instead of matrix.
> 
> 
> Thanks in advance.
> Yersinio.

I couldn't find a 'tree' class either, although I've looked.  However, it should be possible to spin your own by implementing it using an object oriented approach. Here, you create a 'node' class (preferably inherited from the handle class), with a constructor and destructor, and properties that include links to other nodes. You then create a 'tree class' that inherits the properties of the node class and include methods for inserting and deleting nodes, one to walk the tree up and down from its root, etc. You could also include events and event listeners if the application calls for it.

In principle this could be implemented using structures (although I wouldn't even want to try, since using the object oriented class-based approach would be much, much easier).  (Honesty alert: I haven't actually done this yet, but am working on it.) Comments welcome.