[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

=?UTF-8?Q?Re=3A_=5Bxml=2Ddev=5D_Representing_binary_trees_in_XML_=E2=80=

  • From: John Cowan <johnwcowan@gmail.com>
  • To: "Costello, Roger L." <costello@mitre.org>
  • Date: Thu, 4 Jul 2019 13:13:27 -0400

=?UTF-8?Q?Re=3A_=5Bxml=2Ddev=5D_Representing_binary_trees_in_XML_=E2=80=


On Thu, Jul 4, 2019 at 9:45 AM Costello, Roger L. <costello@mitre.org> wrote:
 

Recursive Implementation

The root node consists of a value, an optional left subtree, and an optional right subtree.

A subtree is a node.

A node consists of a value, an optional left subtree, and an optional right subtree.

Here is a recursive XML representation of the above binary tree:

A simpler XML approach is to use elements named root-node, left-node, and right-node.  That reduces the number of levels in the tree by half.

In addition, I don't know of any parsers that use recursion in the language to support recursion in the tree; the nesting is normally stored as an array of element objects, either fixed (in which case you get an error) or growable.  Such a structure can of course be traversed in XSLT, but not with native traversal mechanisms..  Your flat representation doesn't gain you much, then.


John Cowan          http://vrici.lojban.org/~cowan        cowan@ccil.org
Cash registers don't really add and subtract;
        they only grind their gears.
But then they don't really grind their gears, either;
        they only obey the laws of physics.  --Unknown

PNG image



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.