In Progress

PHP5 Binary Tree Class

I need a php 5 Binary tree Class..(with sub nodes class)

The class should be "by the book" (well formatted and documented)

should include a test case

This test case should simulate a db table users as array with following fields

id, referral_id, parent_id, name, (lft, rght)

Structure example:

`````````````1

````2```````````````````3

4``````5````````````6```````7

and should

demonstrate a get all method

-----------------------------------------------------------------------------

This method should populate an array for all tree nodes

array(

[id]=>nodeObj

)

so to get the data from the example

array(

[1]=>nodeObj,

[2]=>nodeObj,

[3]=>nodeObj,

[4]=>nodeObj,

[5]=>nodeObj,

[6]=>nodeObj,

[7]=>nodeObj,

)

demonstrate an insert method

-----------------------------------------------------------------------------

//$name = "User Name"

//$direction = "Left, Right"

$tree->insert($referral_id, $direction, $name);

-- this method should insert into the tree array a new user. The user should be inserted into the first free node in the desired direction under $referal_id;

$tree->insert(1, "left", "John");

Would add a left node to #7.

$tree->insert(3, "right", "Mary");

Would add a right node to #6

Demonstrate a delete method

------------------------------------------------------------------------------

$tree->delete($id);

Delete a node and all subnodes

===============================================================================

NODE OBJ

===============================================================================

Demonstrate a (parents) path method

------------------------------------------------------------------------------

$node->get_path();

Example:

$tree->nodes[7]->get_path();

would give me: array(7, 3, 1);

Demonstrate a children method

------------------------------------------------------------------------------

$node->children($depth = null);

-- get node's children in structured array (with all sub-nodes if depth is not defined)

$tree->nodes[1]->children(1);

results in

array(2,3);

$tree->nodes[1]->children();

results in

array(

2=>array(4,5),

3=>array(6,7);

);

Demonstrate total children method

------------------------------------------------------------------------------

$node->total_children();

$tree->nodes[1]->total_children();

result: 6

Demonstrate a deepest method

------------------------------------------------------------------------------

$node->deepest($direction);

Example

$tree->nodes[1]->deepest("left");

result: 4

$tree->nodes[1]->deepest("right");

result 7

Demonstrate a move method

------------------------------------------------------------------------------

Moves a node (and sub-nodes) to a desired node

this method should work the similar way as insert method... finds the first free spot in the desired direction and appends the node (and sub-nodes) there

$node->move_to($to_id, $direction);

$tree->nodes[2]->move_to(1, "left");

would give me:

`````````````1

````````````````````````3

````````````````````6```````7

```````````````````````````````2

`````````````````````````````4```5

Plus all the other standard methods this classes (should) have

Skills: PHP

See more: php binary tree, tree php5, binary tree php, binary tree php5, php array binary tree, php5 binary tree, formatted binary tree php, php5 tree, php binary tree move, tree structure, tree node, tree insert, tree data structure example, node tree, node data structure, insert binary tree, depth first, data structure node, data structure tree, data structure example, data structure book, data structure binary tree, data structure array, book data structure, binary tree structure

About the Employer:
( 10 reviews ) London, Slovenia

Project ID: #586301

Awarded to:

tomj

Hi, please check PM!

$30 USD in 1 day
(2 Reviews)
1.9

9 freelancers are bidding on average $127 for this job

sristerweb

Done this already. Kindly check PM for more details

$250 USD in 3 days
(246 Reviews)
8.1
rockerstech

I can do it ..

$180 USD in 3 days
(76 Reviews)
7.6
hsoft

please check pmb for more details

$121 USD in 1 day
(34 Reviews)
6.4
Sarvodaya

I am Prakash from Savodaya Institute of Software (www.sisoft.in) India. We are powered by a combination of domain expertise, process skills and superior technology, to offer a predictable process outsourcing experience More

$160 USD in 2 days
(12 Reviews)
5.0
interpb

Hello,Please check your inbox, Thanks

$120 USD in 3 days
(10 Reviews)
4.4
dziban

We are twelve team members who have professionally mastered the skills of Web Design and Development. We have provided excellent quality service within our clients’ budget to their utmost satisfaction. We offers a More

$100 USD in 7 days
(5 Reviews)
4.1
uniquelo

hi, I can provide you the best script with best support. let me know thanks

$150 USD in 3 days
(8 Reviews)
3.7
yonarox

Hi, let me help you

$30 USD in 2 days
(5 Reviews)
1.8