Description

Returns the depth of a given binary tree (BT) starting from the root (root) of the tree.

Code

This script was tested and works on OpenSim version 0.7.5!

///////////////////////////////////////////////////////////////////////////
//    Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3    //
///////////////////////////////////////////////////////////////////////////
integer wasBinaryTreeDepth(list BT, string root) {
    if(root == "") return 0;
    integer left = wasBinaryTreeDepth(BT, wasBinaryTreeLeft(BT, root));
    integer right = wasBinaryTreeDepth(BT, wasBinaryTreeRight(BT, root));
    if(left > right) return left + 1;
    return right + 1;
}

secondlife/binary_trees/depth.txt ยท Last modified: 2022/11/24 07:46 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.