Php and binary tree's - Printable Version +- Computer Tech (https://computertech.createmybb3.com) +-- Forum: Programming (https://computertech.createmybb3.com/forumdisplay.php?fid=6) +--- Forum: Other Programming Languages (https://computertech.createmybb3.com/forumdisplay.php?fid=11) +--- Thread: Php and binary tree's (/showthread.php?tid=139) |
Php and binary tree's - GamingManiac - 01-21-2011 Im here to ask if anyone knows how to go about coding a binary search tree in php I have created this countless times in C++ but I am not comfortable enough in php to attempt it Here is a c++ version I wrote [code]void Bank::add(account* data) //Account Add method { if (accroot == NULL) { accroot = data; return; } account* acurr = accroot; account* aprev; numb_accounts ++; while (acurr) { aprev = acurr; if (data->numb == acurr->numb) acurr = acurr->aright; if (data->numb > acurr->numb) acurr = acurr->aright; else acurr = acurr->aleft; } if (data->numb > aprev->numb) aprev->aright = data; else aprev->aleft = data; }[/code] this adds the numbers to a binary tree based on their value Any ideas how to do the equivalent in php? *EDIT* - Just realised that im making this over complicated Can anyone help me write a php script that, in order to view a page on my site they have to entered a number (ID number) and then have th php check if it is in a text file? RE: Php and binary tree's - Ironside - 01-21-2011 Not me sorry, never did php. |