Em Andamento

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

Habilidades: PHP

Ver mais: php binary tree class, php5 tree class, binary tree class php, php binary tree, php tree class, binary tree php class, tree php5, binary tree php, php class binary tree, binary tree php5, php array binary tree, php5 binary tree, formatted binary tree php, php5 tree, class tree php, php binary tree move, tree structure in c, tree node, tree insert, tree in data structure, tree data structure in c, tree data structure example, tree data structure c, php5.0, obj free

Acerca do Empregador:
( 10 comentários ) London, Slovenia

ID do Projeto: #586301

Premiar a:

tomj

Hi, please check PM!

$30 USD em 1 dia
(2 Avaliações)
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 dias
(246 Comentários)
8.1
rockerstech

I can do it ..

$180 USD in 3 dias
(76 Comentários)
7.6
hsoft

please check pmb for more details

$121 USD em 1 dia
(34 Comentários)
6.4
Sarvodaya

I am Prakash from Savodaya Institute of Software ([url removed, login to view]) India. We are powered by a combination of domain expertise, process skills and superior technology, to offer a predictable process outsourcing experience Mais

$160 USD in 2 dias
(12 Comentários)
5.0
interpb

Hello,Please check your inbox, Thanks

$120 USD in 3 dias
(10 Comentários)
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 Mais

$100 USD in 7 dias
(5 Comentários)
4.1
uniquelo

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

$150 USD in 3 dias
(8 Comentários)
3.7
yonarox

Hi, let me help you

$30 USD in 2 dias
(5 Comentários)
1.8