Pergunta de entrevista da empresa Amazon

Serialize a Binary Tree so that I can create the same tree on another machine.

Respostas da entrevista

Sigiloso

30 de jan. de 2012

Breadth-first algorithm

Sigiloso

5 de fev. de 2012

you shud send two lists.... 1.traversed in "in-order" fashion 2.traversed in "pre-order" fashion

Sigiloso

18 de fev. de 2012

BFS is good. So, lets say we use equal length records and we use some sort of array or file structure. Lets assume for now payload is integer. let bst be such as this 1 2 3 4 0 5 6 0 7 0 0 Serizalize it as D,2,3,D,4,0,D,5,6,,D,0,0,D,0,7,D,0,0,D,0,0