xqian / cpp_projects

cplusplus projects for myself
2 stars 2 forks source link

BST reconstruct, from the (,), try to reconstruct a BST #5

Closed xqian closed 11 years ago

xqian commented 11 years ago

do it in the bst.cc

xqian commented 11 years ago

@xqian test notification

xqian commented 11 years ago

pre_order recursive:(5) pre_order recursive:(5(3),) pre_order recursive:(5,(6)) pre_order recursive:(5(3),(6)) pre_order recursive:(5,(90(40(20(10,(13(12(11),),(15))),(30,(35))),(60(50,(55)),(70(65,(68)),))),))

using a stack to contain all the elements in the string; when encounter an ')', try to pop until '('; put pop out elements into a queue, and from begin to end construct a BST

xqian commented 11 years ago

The last commitment must have memory leak. So I need to clear it.