i***h 发帖数: 12655 | 1 【 以下文字转载自 JobHunting 讨论区 】
发信人: chuncl (ray), 信区: JobHunting
标 题: google inerview question
发信站: BBS 未名空间站 (Thu Jul 17 12:03:08 2008)
Question: How do you put a Binary Search Tree in an array in a efficient manner?
=================================
while there is some guy say using two of in-order, pre-order or post order
would do the work, but i felt it is not the most efficient way.
we can just save it LEVEL by LEVEL in the array. since it is BST not just
binary tree, any comments?
thanks
==== | X****r 发帖数: 3557 | 2 If all keys are unique, just pre-order should be sufficient...
manner?
【在 i***h 的大作中提到】 : 【 以下文字转载自 JobHunting 讨论区 】 : 发信人: chuncl (ray), 信区: JobHunting : 标 题: google inerview question : 发信站: BBS 未名空间站 (Thu Jul 17 12:03:08 2008) : Question: How do you put a Binary Search Tree in an array in a efficient manner? : ================================= : while there is some guy say using two of in-order, pre-order or post order : would do the work, but i felt it is not the most efficient way. : we can just save it LEVEL by LEVEL in the array. since it is BST not just : binary tree, any comments?
|
|