Easily upload multiple usersâ€™ photos to Office 365. Manage them with an intuitive GUI and use handy built-in cropping and resizing options. Link photos with users based on Azure AD attributes. Free tool!

i have no idea where i should ask this question but here is as good as anywhere i guess...

If someone writes down a random number (natural number) what s the best strategy for searching a tree of the following type in order to guess the number:

empty

/ | | \ .....etc

0 1 3 4 .....etc

/ | \ /\ /\ /\ ....etc

00 01 02.........etc

if that makes any sense?

basically its to do with depthfirst/breadthfirst strategies

and id like to know the best strategy for this search without going into an infinite loop...

thanks

paul

If someone writes down a random number (natural number) what s the best strategy for searching a tree of the following type in order to guess the number:

empty

/ | | \ .....etc

0 1 3 4 .....etc

/ | \ /\ /\ /\ ....etc

00 01 02.........etc

if that makes any sense?

basically its to do with depthfirst/breadthfirst strategies

and id like to know the best strategy for this search without going into an infinite loop...

thanks

paul

1 Solution

anyway, since there are infinite natural numbers, BFS is the way to go...

easy implementation (if 00 and 000 are different from 0 say) is

go thru all single digit nos, ie. [0, 9]

then double [00, 99]

then triple blahblah

if 00 is same as 0 then just go from 0 onwards...

of course that is if u can only get the answer to "is __ the number?"

otherwise binary would be best if u can get the answer to "is __ bigger/less than the number?"

searching words in Dictionary.

I would also like to know the answer.

Tackle projects and never again get stuck behind a technical roadblock.

Join Now
Are those numbers or strings ? (00, 01, ...)

Are the numbers in some order in the tree ?

Is the tree finite ?

BTW, is it a tree or a graph ?

In general, you can search any finite tree/graph with either depth-first or breadth-first strategy, without any problem. Breadth-first consumes much more memory, and is usually harder to implement (so depth-first would be the method of choice, unless we know something else :).

For an infinite tree/graph depth first is NOT guaranteed to find the answer, I think, while breadth-first is.

Also, if you have more info about the tree and/or nodes, some other algorithms may be better (A*, branch & bound etc), and if the nodes are ordered, then of course you can do much better :)

Orlando