 |
|
List Archives > 
Maple User Group List Archive > 
Archive by date > 
This Month By Date > 
This Month By Topic
[MUG] Binary Tree Data
| [MUG] Binary Tree Data |
|
Author: Maple User Group
Posted: Mon, 17 Feb 2003 22:15:46 -0500
|
>> From: Maple User Group "maple_gr"
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Sat, 15 Feb 2003 04:38:03 -0500 (EST)
From: Carl Devore "devore"
To: "maple-list"
Subject: Binary Tree Data Structure
On Mon, 3 Feb 2003, Bruno Guerrieri wrote:
> I am trying to use Maple to set up binary trees and work with them.
See ?examples,binarytree
> Since speed is not paramount to what I am doing, is there a
> "construct", (be it artificial and to be refined in future versions),
> a definition-like "thing" that someone could set up at the beginning
> of the worksheet that would allow one to almost translate word for
> word certain C procedures such as node deletion in a tree, exploiting
> the recursive nature of the situation. The construct would, of course,
> be the equivalent of the pointer concept p->left or p->right as one
> can see in the following example:
Yes, they are called modules (see ?module), and as far as I can tell,
there is no performance penalty for using them. The Maple syntax would be
p:-left rather than C's p->left.
A skeleton would be
BinaryTree:= proc(...)
module()
export left, right, ...;
left:= ...;
right:= ...;
...
end module
end proc;
p:= BinaryTree(...);
p:-left;
Note that a procedure that returns a module (as above) is far more
powerful than just a module.
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
From: "Dr Francis J. Wright" "F.J.Wright"
To: "bruno.guerrieri"
Subject: Binary Tree Data Structure
Date: Sun, 16 Feb 2003 17:12:28 -0000
From: "Bruno Guerrieri" "bruno.guerrieri"
To: "maple-list"
Sent: Monday, February 03, 2003 10:52 PM
Subject: [MUG] Binary Tree Data Structure
> I am trying to use Maple to set up binary trees and work with them. Is =
> there a person in the community who has already written the standard =
> procedures for insertion, deletion of nodes etc.. and would not mind =
> sharing?
>
> In addition, although I do not want to go the route of C, C++, etc, the =
> concept of pointer is especially useful when dealing with trees. Since =
> speed is not paramount to what I am doing, is there a "construct", (be =
> it artificial and to be refined in future versions), a definition-like =
> "thing" that someone could set up at the beginning of the worksheet that =
> would allow one to almost translate word for word certain C procedures =
> such as node deletion in a tree, exploiting the recursive nature of the =
> situation.=20
> The construct would, of course, be the equivalent of the pointer concept =
> p->left or p->right as one can see in the following example:
>
> Here is an example of a C procedure
> void printtree(node *p)
> { if (p !=3D NULL)
> { printtree(p->left);
> printf(........,p->count, p->pword);
> printtree(p->right);
> }
> }
You might like to take a look at C:\Program Files\Maple
8\examples\binarytree.mws (although the full pathname of this file may be
different on your installation), which illustrates insertion, deletion, etc.
There is also a similar implementation of linked lists described in the
Maple 8 Advanced Programming Guide. These both use inert functions to
represent nodes.
Alternatively, if you represented a node as a module (or record) then you
could use the object-oriented syntax node:-left etc, which is as close as I
think you will get to C pointer syntax.
Francis
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
From: "Thomas Richard" "t.richard"
To: "maple-list"
Subject: AW: Binary Tree Data Structure
Date: Mon, 17 Feb 2003 09:37:48 +0100
> >> From: "Bruno Guerrieri" "bruno.guerrieri"
>
> Dear MUG
>
> I am trying to use Maple to set up binary trees and work with them. Is =
> there a person in the community who has already written the standard =
> procedures for insertion, deletion of nodes etc.. and would not mind =
> sharing? [...]
I guess ?examples,binarytree has most of what you need.
--
Mit freundlichen Gruessen / best regards
Thomas Richard Tel.: +49-241-40008-52, Fax: -13
Maple Support "mailto:maple.support"
Scientific Computers GmbH <http://www.scientific.de>
|
Previous by date: [MUG] What has MAPLE 7 against MMA 3, Maple User Group
Next by date: [MUG] differental operators, Maple User Group
Previous thread: [MUG] Re: fundamental, Maple User Group
Next thread: [MUG] differental operators, Richard Patterson
|
|
|