Note

The wasBinarySearchTreePredecessor function takes as arguments:

  • a binary search tree (BST) as a flattened list as per binary_trees.
  • the node (node) to find the predecessor of.

and returns the in-order predecessor of the specified node in the binary search tree.

Code

This script was tested and works on OpenSim version 0.7.5!

///////////////////////////////////////////////////////////////////////////
//    Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3    //
///////////////////////////////////////////////////////////////////////////
string wasBinarySearchTreePredecessor(list BST, string node) {
    string left = wasBinaryTreeLeft(BST, node);
    if(left != "") return wasBinarySearchTreeMinimum(BST, left);
    string parent = wasBinaryTreeParent(BST, node);
    while(parent != "" && node == wasBinaryTreeLeft(BST, parent)) {
        node = wasBinaryTreeParent(BST, node);
        parent = wasBinaryTreeParent(BST, parent);
    }
    return parent;
}

secondlife/binary_trees/binary_search_trees/predecessor.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.