Skip to content

jaipack17/roblox-tree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Roblox Tree 🌳

Binary Search Tree Module for Roblox Studio

A binary search tree, also called an ordered or sorted binary tree, is a rooted binary tree whose internal nodes each store a key greater than all the keys in the node's left subtree and less than those in its right subtree.

Example:

       15
       /\
      1  15
       \  \
        4  20
       /
      2
     / \
    1   3

Clone the repository

Place ModuleScript "Node" inside ModuleScript "BinarySearchTree" and place the module inside ReplicatedStorage.

Require the module -

local Tree = require(game:GetService("ReplicatedStorage").BinarySearchTree);

Example -

local Tree = require(game:GetService("ReplicatedStorage").BinarySearchTree)

local tree1 = Tree.new(); -- declaring bst

print(tree1:isEmpty()) -- is the tree empty? (boolean)

tree1:insert(1); -- insert value
tree1:insert(6);
tree1:insert(1);
tree1:insert(8);
tree1:insert(3);

tree1:remove(8); -- remove value

print(tree1);

About

Binary Search Tree Module for Roblox Studio

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages